3D part design with Inkscape and OpenSCAD # 100: Using a non planar slicer to generate gcode for a cnc?

3 min read
By Bob
3D part design with Inkscape and OpenSCAD # 100: Using a non planar slicer to generate gcode for a cnc?

This post is about an experiment I tried to see if I could use a slicer like slic3r or orca slicer to generate gcode for a cnc, the simulations look good but I haven't tried it on a cnc yet and it is definitely a work in progress.

I would caution anyone that doesn't know the ins and outs of a cnc machine to be very careful  when experimenting with things like this, you can damage your machine.

After taking a look at the gcode it was apparent that I needed to get rid of a whole bunch of comments, gcode commands that aren't needed and reverse the direction of the z axis, and while it sounds difficult it was actually pretty simple to automate the process:

I made a script to go through the code line by line and remove what wasn't needed, then reverse the line order so the z-axis commands were in reverse order:

Then I made some changes so that all but the input and output files were removed and the feed rate was able to be changed:

The resulting gcode can then be simulated for use on a cnc machine. Note that I still need to make some changes but this does work well to automate the process. I'm sure there is a better way to do this for someone more familiar with grep, sed, etc.

I set the slicer settings for 100% infill and concentric patterns:

and set the flow rate to zero

After I generate the gcode from the slicer I use the script to set it up for the cnc:

Now when I simulate the gcode the z-axis  goes down instead of up:

Getting a non linear slicer set up is a real pain but I did get it to work, I will do another post on it after I get it to work more consistently, it looks like the non linear implementation in slic3r has quite a few bugs.

Here's a pcb I sliced with "ironing" on the top layer because I was wondering if it can be used like a finishing pass:

I would recommend using software like Kiri:Moto for cnc work, but if you like to experiment and learn this method will be a nice rabbit hole for you.