Difference between revisions of "Programming"
|Line 281:||Line 281:|
Revision as of 09:22, 15 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  and https://github.com/James231/GCode-Razor-PostProcessor 
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
Of especial note is OpenSCAD which has its own page.
- 1 Languages and IDEs which have been used for CNC
- 2 3D Modeling Libraries and Languages
- 2.1 CADquery
- 2.2 Go
- 2.3 Python
- 2.4 Groovy (IDE)
- 2.5 CAD
- 2.6 Lua
- 2.7 Block Editing
- 2.8 Node Editing
- 2.9 Guile/Scheme
- 2.10 Angelscript
- 2.11 3D Representations
- 2.12 Other
- 3 3D printing
- 5 G-Code Libraries and Languages
- 6 G-Code Programming
- 7 G-Code editors
- 8 File formats
- 9 Discussions
- 10 References
Languages and IDEs which have been used for CNC
|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 .
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.
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
- Nodebox (listed above)
- https://gramlanguage.com/ 
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/
|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.
Available for Mac OS X and Linux, there is an effort to build it on Microsoft Windows.
Based on Kokopelli  --- deprecated, c.f., https://github.com/mkeeter/antimony and https://github.com/libfive/libfive  c.f., https://www.gitlab.com/kavalogic-inc/tovero "a binding of Libfive to Common Lisp, including a standalone REPL-based viewer" 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.
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".
|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
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 
Also integrates with: https://cadhub.xyz/
Installing CADquery on Mac OS X
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://www.codelv.com/projects/declaracad/ --- language and application to build 3D models using a subset of the python language called enaml
Python stuff to add for OpenSCAD from the mailing list (find link in forum for footnote)
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 with flex
- Trays and Drawer Inserts
- Parts and Samples
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
https://bitbybit.dev/home --- also allows programming in TypeScript
Blender Node Editing
FreeCAD Node Editing
https://arnholm.github.io/angelcad-docs/ --- angelscript
http://c-csg.com/ --- for use with Linux and GCC
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
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  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://commonwealthrobotics.com/ --- BowlerStudio --- tutorials available: http://commonwealthrobotics.com/BowlerStudio/Welcome-To-BowlerStudio/  
ShapeScript (Mac OS X) https://apps.apple.com/us/app/shapescript/id1441135869?mt=12 
3D printing oriented: https://github.com/jminardi/mecode
- Sample project, a 3-in-1 dock for the Surface: https://github.com/Microsoft/3-in-1-dock
- support for OpenJSCAD: https://maker.js.org/docs/exporting/
- https://github.com/makercam --- Turn maker.js drawings into gcode
(Renamed to jsCAD, but either is acceptable)
- Maker.js support: https://maker.js.org/docs/exporting/
- 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
- Thingiverse: Watercolor Palette
Blockly: http://openjscad.azurewebsites.net/blockly/index.html --- Blocks seem not to work, generating errors
G-Code Libraries and Languages
|Python halftoning program||pixel machining||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.|
|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||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||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
https://github.com/jglauche/CrystalScad --- framework for programming 2d and 3d OpenSCAD models in Ruby
As noted above there is G-Sharp.
https://github.com/arpruss/miscellaneous-scad/blob/master/scripts/gcode2scad.py --- Preview gcode in OpenSCAD 
- syntax-highlighting mode for NotePad++
- (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://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 ..." pairs with http://www.cnc-pad.com/simul-cnc.php
- https://code.visualstudio.com/ 
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://nvbn.github.io/2015/05/28/svg-animation/ --- clojurescript library
- 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
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"