Rewriting gcodepreview with Python

I played with Python and scipy to make something that makes gcode and maintains a height map. It uses a 2D height map grid concept. It might be of interest. If you can make use of the process in it to make a better tool, cool. Just give me some credit. It is not like I set it up for graphical interfaces or anything.

3 Likes

That is very cool!

Also way above my head in terms of math and programming techniques and so forth — I will definitely make a note of it and we will see if it is a good fit at some point in the future — based on discussions on the OpenSCAD mailing list I’ve got some interesting notes on Bézier curves and surfaces…

And I’m now working on unittests, which have been going well:

If anyone has an example project they’d like for me to work through in this, I’d be glad to take a swing at it.

Starting in on another re-write — this one will implement the entire program in Python, then have a very thin OpenSCAD layer on top which can call it, and folks will then be able to use it from either Python (say to make a DXF) or Python in OpenPythonSCAD or OpenSCAD in OpenPythonSCAD.

EDIT: A further thought is it should be possible to set up the Python file so that it can be run from Inkscape as well so as to get an SVG… and a final thought would be that perhaps it could be set up so as to do 3D modeling to match in FreeCAD…

4 Likes

Python re-write progressing, just uploaded 0.7 at the usual place (and made copies of the v0.61 .tex and .pdf files for posterity) — Python core and template done, next up is re-writing the OpenSCAD end of things, but for folks who want to use just Python in OpenPythonSCAD to make 3D models, G-code, or DXFs, you’re good to go.

1 Like

I believe everything is working in Python now:

Next up, developing a compleat set of unit tests for Python, then making sure that I have all the needed G-code commands setup, then we’ll do another upload (if someone wants a copy now, let me know).

2 Likes

Had to pause and do Keyhole toolpaths:

which exports a DXF which can be opened in LibreCAD and exported as an SVG:

aexport

and either the DXF or SVG may be imported into Carbide Create:

(the SVG, while not closed (easily done via Join Vectors), has the advantage of being curves, not polylines):

Hoping to finish the OpenSCAD interface before the next upload.

1 Like

Slight technical issue on the OpenSCAD import, but in the meanwhile, re-worked things so that it will run in “plain” Python:

and make DXF files which may be imported into other applications:

1 Like