Programmatic G-Code Generators

From ShapeOko
Jump to: navigation, search

Note: In addition to the below, OpenSCAD (and ImplicitCAD) use a representational language and are described as "Programmatic CAD" and several similar programs are either listed here, or on the CAD page.

Cf.: Interactive G-Code Generators and .

The Communication / Control program bCNC supports a Python-based macro language for G-code.

In addition, Will Winder's Java Universal-G-Code-Sender has gained a number of features for manipulating G-code files.

3 dimensional control of a beetle (replacement turtle) allows programmatic design of 3D objects in:

Pre-processor which extends Grbl to include much of G-code: [1]

Library which provides PHP 7 functionality for reading and writing from and to 3D objects stored in STereoLithography (STL) files: [2]

Excellent examples of directly programming G-code:

Libraries and Languages

Type Name/Link Description
JavaScript-derived programming language TPL (Tool Path Language) Programming language for creating machine tool paths for CNCs.[3] CAMotics (formerly openscam) has support. Now has an associated project sharing site:
Python front-end for OpenSCAD SolidyPy Use a Python IDE and the Python language to treat objects like objects (not text), use existing OpenSCAD modules, manipulate objects and copy shapes. Extensible.
Python front-end for OpenSCAD SolidPython A python frontend for solid modelling. --- Jupyter Notebook interface

Python front-end for OpenSCAD openpyscad Python library to generate OpenSCAD source intuitively.

Java front-end for OpenSCAD JavaSCAD Representation of OpenSCAD primitive objects with Java objects allowing the building of more complex ones from them.
Python development framework PythonOCC 3D CAD/CAE/PLM development framework for the Python programming language --- provides advanced 2d and 3d geometry modeling structures and algorithms: Bézier BSplines Extrude/revolve/sweep.

Python halftoning program pixel machining[4] Python program to make halftone images out of pixel maps using the Python Imaging Library.
G-Code pre-processor written in Python Mecode Convenient, human-readable layer just above GCode. Written in Python.
G-Code pre-processor JGCGen A G-Code preprocessor and generator based on Apache Velocity.
G-Code pre-processor gcmc Compiler with a context-free grammar and procedural format, which runs scripts to make G-code for a CNC mill. Supports variables and advanced math (scalars, vectors and vector-lists) including mil/mm unit-conversions.[5]
G-Code library written in Python preGrbl Checks and validates g-code compatibility, converts g-code into a more grbl-friendly format, and provides a way to implement and translate canned cycles and other high-level tasks. Written in Python.
TCL g-code preprocessor code gcode and example.tcl TCL program which allows one to program in G-code using TCL to implement loops and other control structures.
Language and IDE (opensource) Processing Processing is an open source programming language and environment to create images, animations, and interactions. See GCtrl and SuperSkein 1.0.

Language and IDE (opensource) NodeBox Cross-platform, node-based GUI for efficient data visualizations and generative design. Used to make a sundial .

Spirograph example sent to a CNC machine and milled.

Note that it uses pixels/points, and scaling and other values are limited in precision, work which requires accuracy would have to be specified in terms of native units.

PostScript to G-Code Converter ps2gc source Command-line utility to convert from (some) PostScript formats to G-Code --- affords the possibility of using tools like Asymptote or METAPOST, may be what was used for NodeBox (above). CF the reverse, gcode2eps which would be very useful for previewing on systems which have Display PostScript.
Python and CNC presentation Python: A "Toy" Language PyCon presentation on using Python (and IPy Notebook) to generate G-code.
Python utilities gctools[6] A set of Python scripts to help create and manipulate CNC gcode files.
Python library pyfab Python library for fab/lab control.See also dxf 1.1.1 a Python library to generate DXFs.
Apt interpreter APTOS Opensource Apt translator project. Consists of several CAM applications, based on the Apt programming language. See APT Tutorial.
Javascript query-like language CadQuery Python based language for building parametric 3D CAD models. Switching to PythonOCC from FreeCAD. Forum:!forum/cadquery Originally at:

Stand-alone GUI under development:

G-code utility grecode Opensource command line utility to shift, rotate, mirror, align gcode. See also JavaScript G-Code Translate, Scale (but not Rotate yet).
G-code utility padder Utility to add spaces to G-Code (also includes Scan2 CNC (convert image to G-Code) and Wrapper (wrap a toolpath around a cylinder for those who have a lathe as a 4th Axis).
G-code utility CNC G Code Arcs to Lines Conversion Program Utility to convert all arcs to straight line segments.

An interesting development is ShopBot's opensourcing of their control language, OpenSBP.

Guile/Scheme: --- --- Linux/Mac OS X GitHub --- Linux/Mac OS X

3D printing

3D printing oriented:

Go --- A simple CAD package using signed distance functions to make STLs. [9]


Maker.js: --- JavaScript library for making OpenSCAD code [10]

Python [11] --- deprecated in favour of and

Python stuff to add for OpenSCAD from the mailing list (find link in forum for footnote)







...and --- language and application to build 3D models using a subset of the python language called enaml [12]

Ruby --- open source project to create a layer on top of Gcode that is a bit more readable, based on Ruby, and as such has access to all of Ruby.[13]


3D modeling (Opensource) --- Flood Free (MIT license) modeling program/programming language source available at: (also listed on the CAD page). --- IDE for Groovy with visual programming options. Used in: using

CAD --- port of Mark Spink's SCILAB/MATLAB toolbox to python

Other --- golang -> stl.[14] [15] --- integration of OpenCascade and MzScheme --- embedded in Python as pyplasm OpenSCAD DSL in Clojure [16] --- specialized high-level programming language intended for modeling geometric objects and their internal volumetric properties [17]

DXF [18]

Vector graphic languages

Logo is notable for being the first, and there are many implementations.

METAPOST --- --- note that MP can now make SVGs directly (and there is wiki support: ) --- note a technique for loading the JSON from an OpenSCAD customizer and using it to generate a PDF or SVG: --- c.f.,





Arguably SVG itself can be hand-coded (the same can be said of PostScript). There are a number of SVG-specific tools:

G-Code editors

See also (listed on the Previewing G-Code page) and (listed on Communication / Control).