From ShapeOko
Revision as of 09:28, 15 July 2021 by Willadams (Talk | contribs) (Block Editing)

Jump to: navigation, search

Naturally, programming may be used in many ways for CNC. The earliest example was of course direct G-Code generation which was the original focus of this page.

Cf.: Interactive G-Code Generators and GSharp, a pre-processor which extends Grbl to include much of G-code: [1] and [2]

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.

Excellent examples of directly programming G-code:

List at:

Of especial note is OpenSCAD which has its own page.

Languages and IDEs which have been used for CNC

Type Name/Link Description
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.

Used to make DXFs for the designs at: --- GUI interface to GRBL V1.1 CNC control using Processing 3.

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. [3]

Vector graphic languages

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

3D Modeling Libraries and Languages

Best represented by OpenSCAD (and ImplicitCAD) there are a wide variety of ways to use a representational language which may be described as "Programmatic CAD" and several similar programs are either listed here, or on the CAD page.

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

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

Type Name/Link Description
3D parametric modeling (Opensource) OpenSCAD Software for creating solid 3D CAD objects, available for Linux/UNIX, MS Windows and Mac OS X. A 3D-compiler that reads in a script file that describes the object and renders the 3D model. Similar on-line tools include CoffeeScad, OpenJsCad and fabfabbers running openscad converted to JavaScript. See also SolidPy, a Python script for manipulating objects. Cf., RapCAD, a system optimized for RepRap 3D printers, Developer’s blog. There is also an app for Android, ScorchCAD.

See also the graphical version or Ulticreator, an interactive front-end for CoffeeSCAD

3D modeling (opensource Linux/Mac) Antimony Computer-aided design (CAD) tool inspired by LISP, based on: framework for tracking information flow through directed acyclic graphs, geometry engine for doing CSG and includes a standard library of shapes and transforms.[6]

Hackaday: Otherworldy CAD software hails from a parallel universe

Available for Mac OS X and Linux, there is an effort to build it on Microsoft Windows.

Based on Kokopelli [7] --- deprecated, c.f., and [8] c.f., "a binding of Libfive to Common Lisp, including a standalone REPL-based viewer"[9] can be integrated with

An early stage of this work was written up in:

3D modeling (Opensource) Flood Free (MIT license) modeling program/programming language source available at:

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. Noted as active.[10] --- Jupyter Notebook interface

Python front-end for OpenSCAD openpyscad Python library to generate OpenSCAD source intuitively. Noted as "kind of active".[11]

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. wrapper for pythonocc

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:

CADquery --- A python parametric CAD scripting framework based on OCCT --- originally developed as a workbench in FreeCAD it is now a stand-alone program. [12] [13]

Also integrates with:

Installing CADquery on Mac OS X

Go --- A simple CAD package using signed distance functions to make STLs (golang -> stl). [14] [15] [16]

Python --- Python library for parametric 3D modeling, uses the geometrical core of the boundary representation OpenCascade.[17] [18]

Note that FreeCAD includes a Python interpreter. c.f.,

PythonOpenScad which describes this sort of thing as "It seems that using Python to produce 3D solid models using OpenScad is a prestigious line of work with a long and glorious tradition. It also seems like lots of dead projects but a popular theme nonetheless." [19] [20] [21] --- language and application to build 3D models using a subset of the python language called enaml [22] [23]

Python OCE Composer

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

...and Described as "gone".[24]

...and Dated to 2016.[25]

...and Dated to 2014. [...and ]

...and Dated to 2012.[26]

...and Dated to 2015.[27]

...and Dated to 2015.[28]



... --- Simple SDF mesh generation in Python.[29] --- A Python macro language to generate GCode

OpenSCAD interface extensible with Python --- Open Source box generator written in Python. It features both finished parametrized generators as well as a Python API for writing your own. It features finger and (flat) dovetail joints, flex cuts, holes and slots for screws, hinges, gears, pulleys and much more.


  • Boxes
  • Boxes with flex
  • Trays and Drawer Inserts
  • Shelves
  • SlatWall
  • Parts and Samples
  • Misc

Groovy (IDE) --- IDE for Groovy with visual programming options. Used in: using

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

Lua --- create OpenSCAD files using Lua script

Typescript --- building and publishing parametric CAD with typescript[30]

Block Editing --- also allows programming in TypeScript

Node Editing

Blender Node Editing

FreeCAD Node Editing


Guile/Scheme: --- --- Mac OS X app available, Linux and Windows require compiling.

Research paper: [31]

Angelscript --- angelscript [32]

3D Representations




Other modeling and slicing for 3D printing with Lua for scripting. [33] [34] --- Javascript wrapper for OpenCascade which runs in a webbrowser. Integrates with [35] [36] --- for use with Linux and GCC [37]

OpenCascade --- integration of OpenCascade and MzScheme --- embedded in Python as pyplasm OpenSCAD DSL in Clojure [38] c.f., "Generate SCAD from Haskell" --- specialized high-level programming language intended for modeling geometric objects and their internal volumetric properties GitHub --- Linux/Mac OS X


ShapeScript (Mac OS X) [41] [42] --- integrates with [43]

3D printing

3D printing oriented:

JavaScript --- JavaScript library for making OpenSCAD code [44]


Maker.js --- a Microsoft Garage project, a JavaScript library for creating and sharing modular line drawings for CNC


(Renamed to jsCAD, but either is acceptable)

Announced on Thingiverse: Early project:






Sample Files:

Interface exemplar: [45]

Image albums:

Blockly: --- Blocks seem not to work, generating errors

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.[46] CAMotics (formerly openscam) has support. Now has an associated project sharing site: --- TPLang (with modifications) -> G-Code in pure JavaScript

Python halftoning program pixel machining[47] 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.[48]
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.
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[49] 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.
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. --- G-Code-Generator, Make CNC programs with fun and interaction

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

C++ --- --- open source computer aided manufacturing algorithms library

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.[50] --- framework for programming 2d and 3d OpenSCAD models in Ruby

G-Code Programming

As noted above there is G-Sharp. --- an example program. --- Preview gcode in OpenSCAD [51]

G-Code editors

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

File formats

DXF [58]




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


References --- "A summary of tools for use in creating drawings (graphs, charts, images, text layouts, etc) from scripts (AppleScript, Perl, Python) on Mac OS X"