Difference between revisions of "Programming"

From ShapeOko
Jump to: navigation, search
(Python)
(Python)
Line 159: Line 159:
  
 
https://github.com/wovo/psml [https://www.reddit.com/r/openscad/comments/fb0fhj/and_another_python_library_that_generates_openscad/]
 
https://github.com/wovo/psml [https://www.reddit.com/r/openscad/comments/fb0fhj/and_another_python_library_that_generates_openscad/]
 
https://pypi.org/project/pygcode/ [https://www.reddit.com/r/CNC/comments/ewp3lp/extract_data_from_gcode_using_python/fg3ix2d/]
 
  
 
https://github.com/arcadeperfect/svg2gcode_grbl [https://www.reddit.com/r/hobbycnc/comments/eiook0/svg2gcode_grbl/]
 
https://github.com/arcadeperfect/svg2gcode_grbl [https://www.reddit.com/r/hobbycnc/comments/eiook0/svg2gcode_grbl/]
Line 197: Line 195:
  
 
... https://github.com/fogleman/sdf --- Simple SDF mesh generation in Python.[https://news.ycombinator.com/item?id=27649268]
 
... https://github.com/fogleman/sdf --- Simple SDF mesh generation in Python.[https://news.ycombinator.com/item?id=27649268]
 
https://github.com/hnez/PYcode --- A Python macro language to generate GCode
 
  
 
https://cadcad.org/
 
https://cadcad.org/
Line 205: Line 201:
  
 
http://graphscad.blogspot.com/
 
http://graphscad.blogspot.com/
 +
 +
====Working with G-Code using Python====
 +
 +
https://pypi.org/project/pygcode/ [https://www.reddit.com/r/CNC/comments/ewp3lp/extract_data_from_gcode_using_python/fg3ix2d/]
 +
 +
https://github.com/cilynx/pygdk
 +
 +
https://github.com/hnez/PYcode --- A Python macro language to generate GCode
  
 
====Boxes.py====
 
====Boxes.py====

Revision as of 04:27, 6 October 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

https://www.reddit.com/r/cad/comments/hyah4m/open_source_scriptable_cad_engines_that_have_fast/

List at: https://learn.cadhub.xyz/blog/curated-code-cad/

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.

https://medium.com/@ProcessingOrg/thoughts-on-software-a8a82c95e1ad#.5epe1jlml

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

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

https://tutorial45.com/free-solidworks-alternative/

https://www.reddit.com/r/hobbycnc/comments/bdvd9h/floodeditor_parametric_cad_system_under_mit/

https://www.reddit.com/r/cad/comments/bdvcnt/parametric_cad_system_under_mit_license/

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://www.reddit.com/r/Python/comments/2ukppo/python_occ_a_parametric_3d_cad_software/

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

https://pythonhosted.org/cadquery/intro.html

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

CADquery

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]

Also integrates with: https://cadhub.xyz/

Installing CADquery on Mac OS X

https://docs.anaconda.com/anaconda/install/mac-os/

https://cadquery.readthedocs.io/en/latest/installation.html

Go

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

Python

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]

https://pypi.org/project/BlendSCAD/

Note that FreeCAD includes a Python interpreter. c.f., https://wiki.freecadweb.org/Python_scripting_tutorial and 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/mrRobot62/GCodeGenerator_Geometricals

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

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

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

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

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

https://vpython.org/

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".[23]

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

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

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

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

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

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

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

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

https://cadcad.org/

OpenSCAD interface extensible with Python

http://graphscad.blogspot.com/

Working with G-Code using Python

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

https://github.com/cilynx/pygdk

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

Boxes.py

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.

featuring:

  • 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

CAD

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

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

https://github.com/fablab-ka/OpenSCAD2D --- 2D CAD in Python to make DXFs inspired by OpenSCAD

Lua

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

https://wiki.librecad.org/index.php?title=LibreCAD_3_-_Lua_Scripting


Typescript

http://www.dynamaker.com --- building and publishing parametric CAD with typescript[30]

Block Editing

http://beetleblocks.com/

https://makecode.buildbee.com/

https://www.blockscad3d.com/

https://bitbybit.dev/home --- also allows programming in TypeScript

Node Editing

Blender Node Editing

https://github.com/nortikin/sverchok

FreeCAD Node Editing

https://github.com/infeeeee/DynFreeCAD

https://github.com/microelly2/NodeEditor

Guile/Scheme

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/ [31]


Angelscript

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

https://github.com/arnholm/angelcad

https://www.abmesh.com/try-angelcad/

https://github.com/arnholm/angelcad-samples [32] https://news.ycombinator.com/item?id=24243077


3D Representations

OpenCSG: http://opencsg.org/

OpenCascade https://en.wikipedia.org/wiki/Open_Cascade_Technology

NURBS: https://www.reddit.com/r/CNC/comments/okn804/are_there_any_3d_engines_that_are_geared_towards/

Other

http://www.salome-platform.org/

http://www.loria.fr/~slefebvr/icesl/ modeling and slicing for 3D printing with Lua for scripting. https://news.ycombinator.com/item?id=24513722

https://github.com/naramski/cadmelia --- Java implementation of OpenSCAD modeling language

https://github.com/miguelitoelgrande/BlenderSCAD

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

https://github.com/cbiffle/ruckus [33] [34]

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

https://gitlab.com/mixotricha/elixir-makertron

https://www.reddit.com/r/CNC/comments/m8xbcp/javacnc_object_oriented_cnc_machine_programming/

https://github.com/zalo/CascadeStudio --- Javascript wrapper for OpenCascade which runs in a webbrowser. Integrates with https://cadhub.xyz/

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

https://thi.ng/

https://nodi3d.com/ [36]

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/ [37]

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/

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 [38] 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

https://github.com/OpenNURBS/OpenNURBS

http://libnurbs.sourceforge.net/

https://tinyspline.org/

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

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

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

https://github.com/kovacsv/VisualScriptCAD

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

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

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

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 [44]

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

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

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

Documentation:

Implementations:

Gallery:

Articles:

Sample Files:

Interface exemplar:

https://gen.haxit.org/organizer/ [45] 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

https://makerscad.com/

Related projects:

https://github.com/velociwabbit/JSONCad

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: 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[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. 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.[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.

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

https://github.com/mrRobot62/GCodeGenerator_Geometricals

https://github.com/ryansturmer/node-gcode

http://emc.sourceforge.net/NIST-archive/msg01624.html

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

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 [51]

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

DXF

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

Python

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

https://ezdxf.mozman.at/

STL

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

Directly making an STL using Python: https://micronote.tech/2020/12/Generating-STL-Models-with-Python/

SVG

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

Discussions

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

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

https://www.reddit.com/r/maker/comments/erksu0/i_am_writing_my_own_cad_software/

https://www.reddit.com/r/flossCAD/comments/g6m50n/my_adventure_with_flosscad_the_design_of_a_board/

References

https://rosettacode.org/wiki/Yin_and_yang#Metapost

http://papers.cumincad.org/data/works/att/caadria2016_157.pdf

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"

https://gabrielgambetta.com/computer-graphics-from-scratch/