Sunday, July 4, 2010

HeeksCNC + python == APT360

One of my favorite CNC programming languages is APT360. It's a totally parametric way of creating gcode for cnc machines. It's also not very user friendly, if you don't use it all the time and get rusty, like I do. I'm a big fan of parametric programming and also a big fan of the python programming language. It's fairly easy for a non programming like me to get into and it's very popular, so there are many resources on the web for it.
In one of my previous blog entries, I mentioned that HeeksCNC uses python as the underlying scripting between the main C++ code and the post processed g-code. This week, Dan Heeks introduced a blank scipting object in HeeksCNC that lets the user create scripts in python and retain them in the order wanted in the HeeksCAD file. 'New Script Operation', as it's named in the HeeksCNC machining menu let's you do anything that you can think of in python and insert it into the Heeks python output.
As soon as I got my hands on the source code and compiled it, I started playing with parametric holes and helix operations.

Here is a small and very limited script for creating a helix in gcode:

def helix(x_cen,y_cen,z_depth,dia,pitch,z_clear):

    while (z_depth < z_clear):


        z_depth= z_depth+pitch


This snippet of code doesn't take into account anything having to do with tool radius/diameter.

Here you can see that I mixed script ops and a regular profile machining op:

Fun stuff!