I had a Prusa I3 3D Printer which use Arduino Mega 2560, Ramps 1.4 and Pololu - A4988 Stepper Motor Driver.

enter image description here

I want to convert my 3D printer to CNC Router using my Dremel with Flexible shaft like this. enter image description here enter image description here

I found the one project on instructables.com at here http://www.instructables.com/id/Arduino-Controlled-CNC-3D-Printer

They give config for Mega 2560 as CNC router. But i don't know how to generate g-code for these cnc router.

Please help me to generate g-code from STL, DXF and Image(PNG or SVG) files to use with this type of cnc router.

  • Inkscape (free) will generate gcode from an svg using "gcode tools" add-on (also free)
    – Bob
    Commented Feb 23, 2019 at 23:47

1 Answer 1


For generating g-code from an SVG, you could try to parse the SVG into a set of relative commands, and using the relative commands to generate G-code. Since you were originally using the frame as a 3d printer and now you want to use this as a CNC machine, you could try to invert the data. But, for generating the code I would go read up on how to parse the various file formats, and read the specs on each of the formats. However, most of the file formats you listed are proprietary, and you won't be able to find an open spec for them.

Of the formats that you listed, it would probably be the easiest to parse the SVG, as it's an open spec, and is a lot like XML.

This is going to be really difficult to actually do, because you're essentially reimplementing a full CNC controller.

I would start with getting 2 dimensional stuff down like drawing shapes and setting routing depth.

Some Resources

Here are some resources that might help you with parsing the various file formats. I only listed the ones that have an open standard.

Not the answer you're looking for? Browse other questions tagged or ask your own question.