Has anybody generated G-code (used for controlling milling machines and plotters and other hardware) in Mathematica? High quality inexpensive plotters have reached the market and I would like to drive one directly from Mathematica if possible.

A related question was asked on Reddit last year (https://www.reddit.com/r/Mathematica/comments/3ouex6/gcode_using_mathematica/) but I suspect greater expertise exists here.

  • 1
    $\begingroup$ There are many G-code subsets around. As for Line (2/3D) and Circle (2D) primitives , the translation should be straightforward. Perhaps you can add a sample path? Generation in the sense of subtractive CAM (milling) from generic 2D/3D objects can become arbitrarily complex though... $\endgroup$ – Yves Klett Apr 16 '16 at 7:32
  • $\begingroup$ @YvesKlett My needs are very basic, purely two-dimensional. That said, I've no experience with G-code and I'm wary of starting from scratch. I may end up with a Mathematica -> DXF -> Python -> GCode chain, however inelegant. $\endgroup$ – Michael Stern Apr 16 '16 at 16:32
  • $\begingroup$ I coded a postprocessor for an obscure CNC-code (.ncp) years ago. That can be done with a few lines... if you add an example with Mathematica primitives and expected G-code output, that should help getting you there... especially if you don't need directed arcs and only lines/polylines. $\endgroup$ – Yves Klett Apr 16 '16 at 17:39
  • $\begingroup$ Michael, how about adding that example? This is a good question... $\endgroup$ – Yves Klett Apr 19 '16 at 16:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.