Previewing G-Code using OpenSCAD

Python would be awesome, but JavaScript would probably be nicer in terms of providing access to folks.

In this case, brute-forcing is a series of If… end ifs:

For 90 degree arcs we seem to need a total of 8 different modules (CW/CCW and upper left, upper right, lower right, and lower left):

They’ll then be stitched into a single module which calculates which quadrant a given arc covers — working up a more general module which determines the arc angles as well will wait until that is needed for a project.

The garc modules are done — two versions, CW and CCW, though they’re a bad hack in that I just re-used existing arc modules, so directionality isn’t correct, and only 90 degree arcs are possible — addressing these failings will be done in a future update.

BlockSCAD version is available at:

https://www.blockscad3d.com/community/projects/1244473

You define the stock size (this will need to go into comments in the G-Code) and only bottom left spoilboard surface is possible as an origin at this time — adding at least options to match Carbide Create’s settings will need to be a future update.

The other missing element is cove radius endmills — only have this code in OpenSCAD, so it will need to be merged in when the OpenSCAD code is placed on GitHub.

There are examples of all the possible cuts:

including some which are commented out:

Put things up on GitHub:

Next up is actually putting this to use (and then improving it and fixing any bugs)

To put it to use, rather than Livecode (which I did my initial proof of concept in), shifting over to Python — first step is working up an interface which will allow customizing numbers and setting filenames and so forth and having a couple of buttons to write out the files:

EDIT: Things look better w/ the numbers centered — will have to look into decimal aligning them.

Using pycharm as an IDE, so the file is “main.py”:

main.zip (1.7 KB)

Just the skeleton of things — actually coding things up is next.

EDIT: filename insertion now works, and writing out a sample file, and getting the “Preview in OpenSCAD” button to load and render the file, so on to actual coding — writing out lines and arcs should both be in place, so next up is working out the mechanics of keeping track of the current tool and working up stuctures for actually cutting.

This is being continued at:

EDIT:

and an initial proof of concept file is done: