Programming

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

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

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


 * METAPOST --- https://commons.m.wikimedia.org/wiki/File:Cribbage_Board.svg --- note that MP can now make SVGs directly (and there is wiki support: https://www.mediawiki.org/wiki/Extension:Metapost ) --- note a technique for loading the JSON from an OpenSCAD customizer and using it to generate a PDF or SVG: http://community.carbide3d.com/t/cnc-finger-joint-box/8880 --- c.f., http://pyx.sourceforge.net/examples/drawing/metapost.html
 * Asymptote
 * Nodebox (listed above)
 * https://archives.haskell.org/projects.haskell.org/diagrams/

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

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

Python
Note that FreeCAD includes a Python interpreter.

https://pypi.org/project/pygcode/

https://github.com/arcadeperfect/svg2gcode_grbl

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 http://www.pyxplot.org.uk/

http://savannah.nongnu.org/projects/soya3d/

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

https://vpython.org/

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

...and https://github.com/SquirrelCZE/pycad/

...and https://github.com/vishnubob/pyscad

...and https://github.com/bjbsquared/SolidPy

...and https://github.com/acrobotic/py2scad

...and https://github.com/TheZoq2/py-scad

...and https://github.com/defnull/pyscad

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

OpenSCAD interface extensible with Python
http://graphscad.blogspot.com/

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

CAD
http://tenko.github.io/occmodel/index.html#examples

https://code.google.com/archive/p/caddd/

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

http://diyhpl.us/cgit/lolcad

Other
https://arnholm.github.io/angelcad-docs/ --- angelscript

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

http://blackjk3.github.io/threefab/

https://github.com/thi-ng/morphogen

http://structuresynth.sourceforge.net/

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

http://www.omnigia.com/SchemeCad/

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

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

https://github.com/arnholm/angelcad https://www.abmesh.com/try-angelcad/ https://github.com/arnholm/angelcad-docs https://github.com/arnholm/angelcad-samples

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

https://github.com/OpenNURBS/OpenNURBS

http://libnurbs.sourceforge.net/

https://tinyspline.org/

Guile/Scheme: https://libfive.com/ --- https://github.com/libfive/libfive --- Linux/Mac OS X

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


 * http://commonwealthrobotics.com/ --- BowlerStudio --- tutorials available: http://commonwealthrobotics.com/BowlerStudio/Welcome-To-BowlerStudio/
 * http://commonwealthrobotics.com/SimpleJavaTutorial/binary/
 * http://commonwealthrobotics.com/JavaCAD/Overview/

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

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

JavaScript
http://snapsvg.io/

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

https://github.com/ghemingway/cad.js/tree/master

https://www.viewstl.com/plugin/

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


 * https://www.microsoft.com/en-us/garage/#garage-workbench
 * https://www.microsoft.com/en-us/garage/profiles/maker-js/
 * Sample project, a 3-in-1 dock for the Surface: https://github.com/Microsoft/3-in-1-dock
 * https://mspoweruser.com/meet-microsofts-maker-js-a-javascript-library-for-creating-drawings-for-cnc-and-laser-cutters/
 * https://www.bigbluesaw.com/big-blue-saw-blog/general-updates/design-without-cad-using-maker-js.html
 * support for OpenJSCAD: https://maker.js.org/docs/exporting/
 * https://github.com/makercam --- Turn maker.js drawings into gcode

OpenJsCAD
(Renamed to jsCAD, but either is acceptable)

Announced on Thingiverse: https://www.thingiverse.com/thing:16272 Early project: https://www.thingiverse.com/thing:16329

https://github.com/jscad

Documentation:


 * https://openjscad.org/dokuwiki/doku.php?id=start
 * http://wiki.bitplan.com/index.php/OpenJSCAD
 * Deprecated? https://github.com/jscad/OpenJSCAD.org/issues/446
 * https://en.wikibooks.org/wiki/OpenJSCAD_User_Guide
 * https://en.wikibooks.org/wiki/OpenJSCAD_Quick_Reference
 * Maker.js support: https://maker.js.org/docs/exporting/

Implementations:


 * Implementation available from the Microsoft Store: https://www.microsoft.com/en-us/p/openjscad/9nblggh6j6j9 which supports Blockly Blocks programming (also available from: http://openjscad.azurewebsites.net/ )
 * http://www.z3d.jp/lab/view.php?design=lab-000000008 --- notable for instantiating interface
 * http://www.ersl.wisc.edu/software/CADjs/CADjsFiles/CADjs.html

Gallery:


 * https://github.com/danmarshall/jscad-gallery
 * http://www.z3d.jp/lab/

Articles:


 * https://www.allwinedesigns.com/blog/cost-savings-using-openjscad
 * https://www.hanselman.com/blog/CreatingExact3DModelsFor3DPrintingWithJavaScriptAndOpenJSCAD.aspx
 * https://blogs.msdn.microsoft.com/synergist/2015/12/10/watercoloring-3d-printing-cad-hour-of-code-windows-apps-and-the-creative-process/

Sample Files:


 * Thingiverse: Watercolor Palette
 * https://www.thingiverse.com/thing:20816
 * https://openjscad.nodebb.com/topic/88/a-little-web-app-using-openjscad
 * https://gitlab.com/johnwebbcole/vesa-shelf
 * http://falldeaf.com/2016/04/openjscad-radial-wire-organizers/

Interface exemplar:

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

Image albums:


 * https://imgur.com/a/fg8vz
 * https://imgur.com/a/acWGBco

Blockly: http://openjscad.azurewebsites.net/blockly/index.html --- Blocks seem not to work, generating errors

https://makerscad.com/

G-Code Libraries and Languages
An interesting development is ShopBot's opensourcing of their control language, OpenSBP.

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

Ruby
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.

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

G-Code editors

 * syntax-highlighting mode for NotePad++
 * http://www.addyourservice.net/notepadppcncsyntax.php
 * https://github.com/robEllenberg/gcode-syntax
 * http://zero-divide.net/?shell_id=151&article_id=4809_notepad-absolutely-free-g-code-editor-with-code-highlighting
 * (free) Editor just for G-Code with syntax highlighting: http://www.cnccoder.com/
 * EdytorNC --- Text editor for CNC programmers. Features include: bolt holes calculation; solutions of triangles calculation; speed, feed calculation; conversion inch/mm, mm/inch; code coloring; RS232 data transmission
 * https://github.com/robotmaster/sublime-text-syntax-highlighting
 * https://bitbucket.org/Groomblecom/gcode-editor --- Java (Swing) app intended for editing G-code for 3D printers
 * Gedit --- has a G-code syntax highlighting mode.
 * https://atom.io/packages/g-code
 * https://cnc-pad.com/ --- seems to be oriented to industrial machines noting support "...for the most common G-CODE languages, Fanuc, Siemens, Heidenhain, etc ..."

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).

DXF
https://github.com/yofu/dxf

Python
https://pypi.org/project/dxf/

STL
https://help.github.com/articles/3d-file-viewer/

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


 * https://ravichugh.github.io/sketch-n-sketch/ --- notable for allowing manipulation of the output to be reflected in the code.
 * http://projects.haskell.org/diagrams/ --- flexible, declarative domain-specific language for creating vector graphics, using the Haskell programming language. c.f., http://savannah.nongnu.org/projects/funcmp/
 * https://bonsaijs.org/
 * https://nvbn.github.io/2015/05/28/svg-animation/ --- clojurescript library
 * http://www.calormen.com/jslogo/
 * Oblivion Github --- programming language that compiles to SVG files.... designed to visualize code and create ... illustrations. Features: SVG-specific data structures and operators, Simple, Ruby/Python like syntax, Runs in the browser, or in NodeJS, Recursion and functional programming support, Immutable Python-style lists
 * http://snapsvg.io/
 * https://github.com/d3/d3/wiki/Gallery

Discussions
http://galaxykate0.tumblr.com/post/139774965871/so-you-want-to-build-a-generator

https://emacstragic.net/2013/05/27/programmatic-cad-openscad-alternatives/