After I built my CNC I started getting requests from students (and even a prof) to make parts for their projects. There was apparently a lot of red tape around the school equipment. I had this idea to make a web-based CAM system with a quote function (ie. ponoko for CNC)

I dubbed this flash-based CAM program "PartKAM" (which stands for kick-ass machining)

it's still online at

the sources are available on launchpad. It's about 20k lines of actionscript 3.

I added some drawing functions to quickly sketch out shapes. This probably isn't that useful since you'd want to do CAD in another program, but I had read a few papers on sketch-to-vector conversion and wanted to try it out.

The core algorithm in a CAM package is the calculation of offsets. This is basically the "path offset" feature in illustrator, but for CAM you would need to adhere to specific tolerances.

To mill a pocket for example, you would just offset the outer contour a bunch of times until the entire area inside is covered.

The offset algo is deceptively simple. The key problem is figuring out which pieces to keep and which to remove in a way that's not O(n^2)

I read some papers on this and the state of the art here appears to be using a generalized Voronoi diagram (ie. a Voronoi diagram generated from both lines and points) to find the medial axis of the graph, but that stuff is a bit above my paygrade.

I came up with a neat hack to get around this using the bitmap functions of the flash api. The nice thing about this approach is that you can control precision through the size of the bitmap, and it has the potential to be hardware-accelerated.

I was playing around with genetic algorithms (which are surprisingly easy to work with), and I thought I'd add an interesting function to the program.

The nesting problem is NP-Complete, which for non-trivial sets means it's basically a game of guess and check. The approach here is to insert each piece with a certain gravity (eg. always to the lower left), rotate to a set angle, and so on until all pieces are inserted. The insertion order and rotation angles form the genome for each individual solution set, then it's just a matter of mutating and crossing the genome to get better results in each successive generation.

Flash has the annoying problem of not updating the ui when doing something in the background, I had to implement "green threads" to chop the processor-intensive parts into digestible chunks. That wasn't very fun.

I haven't worked on this thing for a while, but I hear it lives on as "makercam".

up arrow Back to top