Difference between revisions of "Programming"

From ShapeOko
Jump to: navigation, search
Line 247: Line 247:
Guile/Scheme: https://libfive.com/ --- https://github.com/libfive/libfive --- Mac OS X app available, Linux and Windows require compiling.
Research paper: https://www.mattkeeter.com/research/mpr/ [https://news.ycombinator.com/item?id=26873691]
Line 299: Line 307:
Guile/Scheme: https://libfive.com/ --- https://github.com/libfive/libfive --- Linux/Mac OS X
http://www.curv3d.org/ [https://github.com/curv3d/curv GitHub] --- Linux/Mac OS X
http://www.curv3d.org/ [https://github.com/curv3d/curv GitHub] --- Linux/Mac OS X

Revision as of 08:57, 9 July 2021

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: https://github.com/NRSoft/GSharp [1] and https://github.com/James231/GCode-Razor-PostProcessor [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: http://www.sawmillcreek.org/showthread.php?244397-Some-CNC-work


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: http://atfab.co/

https://github.com/TPMoyer/Grbl4P --- 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 https://www.nodebox.net/code/data/media/sundial-slant.pdf .

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.

http://heavyfishdesign.com/ [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: http://beetleblocks.com/

Library which provides PHP 7 functionality for reading and writing from and to 3D objects stored in STereoLithography (STL) files: https://packagist.org/packages/php3d/stl [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 https://www.blockscad3d.com/editor/# or Ulticreator, an interactive front-end for CoffeeSCAD

See also http://www.loria.fr/~slefebvr/icesl/ which adds slicing for 3D printing.

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., https://github.com/mkeeter/antimony and https://github.com/libfive/libfive [8] c.f., https://www.gitlab.com/kavalogic-inc/tovero "a binding of Libfive to Common Lisp, including a standalone REPL-based viewer"[9] can be integrated with https://www.gitlab.com/kavalogic-inc/clive

An early stage of this work was written up in: http://mattkeeter.com/research/thesis.pdf

3D modeling (Opensource) Flood Free (MIT license) modeling program/programming language source available at: http://www.github.com/pboyer/flood




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]

https://pypi.org/project/viewscad/ --- 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.


https://github.com/charles-sharman/ccad wrapper for pythonocc

Javascript query-like language CadQuery Python based language for building parametric 3D CAD models. Switching to PythonOCC from FreeCAD. Forum: https://groups.google.com/forum/#!forum/cadquery Originally at: https://github.com/dcowden/cadquery


Stand-alone GUI under development: https://github.com/jmwright/cadquery-gui


https://github.com/CadQuery/cadquery --- A python parametric CAD scripting framework based on OCCT --- originally developed as a workbench in FreeCAD it is now a stand-alone program. https://github.com/cqparts/cqparts [12]

https://github.com/winksaville/cq-box-with-dovetail-lid [13]

Installing CADquery on Mac OS X




https://github.com/deadsy/sdfx --- A simple CAD package using signed distance functions to make STLs (golang -> stl). [14] [15] [16]


https://mirmik.github.io/zencad/en/ --- Python library for parametric 3D modeling, uses the geometrical core of the boundary representation OpenCascade.[17]

https://think.cs.vt.edu/blockpy/blockpy/load [18]

Note that FreeCAD includes a Python interpreter. c.f., https://github.com/supermerill/FreePySCAD

PythonOpenScad https://bitbucket.org/owebeeone/pythonopenscad/src/master 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." https://www.bvcw.org/


https://github.com/wovo/psml [19]

https://pypi.org/project/pygcode/ [20]

https://github.com/arcadeperfect/svg2gcode_grbl [21]

https://www.codelv.com/projects/declaracad/ --- language and application to build 3D models using a subset of the python language called enaml

https://github.com/orbingol/NURBS-Python [22] http://www.pyxplot.org.uk/


http://pythoncad.sourceforge.net/dokuwiki/doku.php?id=program_code_description [23]


Python OCE Composer https://github.com/jepler/poc https://emergent.unpythonic.net/01501986387

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

...and https://github.com/SquirrelCZE/pycad/ Described as "gone".[24]

...and https://github.com/vishnubob/pyscad Dated to 2016.[25]

...and https://github.com/defnull/pyscad Dated to 2014. [...and https://github.com/defnull/pyscad ]

...and https://github.com/bjbsquared/SolidPy Dated to 2012.[26]

...and https://github.com/acrobotic/py2scad Dated to 2015.[27]

...and https://github.com/TheZoq2/py-scad Dated to 2015.[28]

...and https://github.com/jed-frey/CNC3018

...and https://sourceforge.net/projects/elcad/

... https://github.com/fogleman/sdf --- Simple SDF mesh generation in Python.[29]

https://github.com/hnez/PYcode --- A Python macro language to generate GCode

OpenSCAD interface extensible with Python



http://www.festi.info/boxes.py/ --- 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)

https://vrl-studio.mihosoft.eu/ --- IDE for Groovy with visual programming options. Used in: https://www.thingiverse.com/thing:3101675 using https://github.com/miho/VRL-VCSG


http://tenko.github.io/occmodel/index.html#examples https://emergent.unpythonic.net/01501548515


http://runten.tripod.com/NURBS/ --- port of Mark Spink's SCILAB/MATLAB toolbox to python



https://github.com/thechillcode/Lua_CAD --- create OpenSCAD files using Lua script


Block Editing


Node Editing

Blender Node Editing


FreeCAD Node Editing




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

Research paper: https://www.mattkeeter.com/research/mpr/ [30]



https://github.com/cbiffle/ruckus [31] [32]

https://scriptcad.org/ https://xyzdims.com/2019/12/29/cad-scriptcad-org-prototype-2019-12/




http://web.ist.utl.pt/antonio.menezes.leitao/Rosetta/tutorials/introduction.html [33]


https://nodi3d.com/ [34]

https://arnholm.github.io/angelcad-docs/ --- angelscript https://github.com/arnholm/angelcad https://www.abmesh.com/try-angelcad/ https://github.com/arnholm/angelcad-docs https://github.com/arnholm/angelcad-samples [35] https://news.ycombinator.com/item?id=24243077

http://c-csg.com/ --- for use with Linux and GCC



http://structuresynth.sourceforge.net/ [36]

https://github.com/avalero/OOML https://hackaday.com/2017/01/03/ditch-openscad-for-c/ https://www.researchgate.net/publication/254034593_Boosting_mechanical_design_with_the_C_OOML_and_open_source_3D_printers


OpenCascade https://github.com/tpaviot/oce

www.dia.uniroma3.it/~scorzell/cscheme/index.htm --- integration of OpenCascade and MzScheme

http://www.plasm.net/ --- embedded in Python as pyplasm

https://github.com/farrellm/scad-clj OpenSCAD DSL in Clojure https://github.com/adereth/dactyl-keyboard https://www.youtube.com/watch?v=uk3A41U0iO4 [37] c.f., https://github.com/farrellm/scad-hs "Generate SCAD from Haskell"

http://hyperfun.org/wiki/doku.php?id=hyperfun:main --- specialized high-level programming language intended for modeling geometric objects and their internal volumetric properties

http://verbnurbs.com/ https://github.com/pboyer/verb




http://www.curv3d.org/ GitHub --- Linux/Mac OS X

Blockly: https://blockly-demo.appspot.com/static/demos/code/index.html



ShapeScript (Mac OS X) https://apps.apple.com/us/app/shapescript/id1441135869?mt=12 [40]

https://bitbybit.dev/app [41]

https://zalo.github.io/CascadeStudio/ --- integrates with https://cadhub.xyz/ [42]

3D printing

3D printing oriented: https://github.com/jminardi/mecode



https://github.com/tasn/scadjs --- JavaScript library for making OpenSCAD code [43]




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: https://www.thingiverse.com/thing:16272 Early project: https://www.thingiverse.com/thing:16329


Discussion: https://news.ycombinator.com/item?id=22527166





Sample Files:

Interface exemplar:

https://gen.haxit.org/organizer/ [44] https://www.reddit.com/r/lasercutting/comments/7x5wug/i_made_a_parametric_organizer_with_openjscad/

Image albums:

Blockly: http://openjscad.azurewebsites.net/blockly/index.html --- 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.[45] CAMotics (formerly openscam) has support. Now has an associated project sharing site: https://projects.buildbotics.com/doug/TPL_Helper_Library

https://github.com/makercam/openjscam --- TPLang (with modifications) -> G-Code in pure JavaScript

Python halftoning program pixel machining[46] 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. http://www.vagrearg.org/content/gcmc
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.[47]
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[48] 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.

https://github.com/gcogen/gcogen --- G-Code-Generator, Make CNC programs with fun and interaction




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


http://www.anderswallin.net/CAM/ --- https://github.com/aewallin/opencamlib --- open source computer aided manufacturing algorithms library


https://github.com/kodaxx/Rcode --- 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.[49]

https://github.com/jglauche/CrystalScad --- framework for programming 2d and 3d OpenSCAD models in Ruby

G-Code Programming

As noted above there is G-Sharp.

https://community.carbide3d.com/t/generating-toolpaths-with-g-code-macros-unsupported-by-grbl/27561 --- an example program.

https://github.com/arpruss/miscellaneous-scad/blob/master/scripts/gcode2scad.py --- Preview gcode in OpenSCAD [50]

G-Code editors

See also http://nc-corrector.inf.ua/index_EN.htm (listed on the Previewing G-Code page) and https://sourceforge.net/projects/gcodedownloader/ (listed on Communication / Control).

File formats


https://github.com/yofu/dxf [57]







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









https://www.peter.com.au/programming/scripted-drawing.html --- "A summary of tools for use in creating drawings (graphs, charts, images, text layouts, etc) from scripts (AppleScript, Perl, Python) on Mac OS X"