Lurker News

Comments (74) 30 threads

Show all comments

Showing thread 6 of 30

roland351 reply#
This is great! I just created a pen holding adapter for my 3d printer so I can do some plots. I still need to find a good way to efficiently convert SVG files to gcode, but this will be a good start.

Inkscape has a gcode generation tool, but it requires some tweaks to work on my prusa 3d printer. Still a work in progress!

londons_explore3 replies#
It's just a list of X, Y coordinates...

An untested python one-liner:

    '\n'.join(["G0 X"+x+" Y"+y for x,y in coords])
Grab the code for homing and stuff from the start of another gcode file that works.
lights0123#
(In the context of this post, which is just straight lines)
paulgb#
If you can use an editor like Inkscape to flatten the image (by recursively ungrouping until every path is under the top-level tag), you should have a bunch of paths that share a coordinate space. There are pathological cases like images that use CSS for positioning, but for most cases this will work.

Then you can use something like svgpathtools (https://github.com/mathandy/svgpathtools) in Python to loop over the paths and get the coordinates.
In case it's useful, I have an example svg to gcode converter here: https://github.com/paulgb/penkit/blob/master/penkit/polargra...
It is for driving a polargraph-style plotter, so it includes a coordinate transform that GP does not need to do.

roland35#
Curves can be a bit more complicated, plus generating the tool lift and moves! I also need to factor in scaling the drawing as well, plus speeds.