Generate gcode to plot on a 3d printer with a pen
2d plotting on a 3d-printer
This python library generates GCODE from SVG paths, allowing a 3d printer to draw images with a pen.
Attach a pen to the printer
In order to draw images, we need to attach a pen to the printer. I've used this model to attach a pen to my Mk3S
pip install plotting3dprinter
obtain SVG file
to generate GCODE a vector-based SVG image file is required. Currently the library only accepts paths made out of lines and splines (cubic and quadratic). Transformed paths and groups are not (yet) supported. The examples folder on this repo contains some compatible SVG files.
Software to generate SVG images from a bitmap image which worked well for me is Potrace.
The vector images generated by potrace need some addititional cleaning up using for example Inkscape. Make sure there are no groups and that the paths use absolute positioning. In settings, under "SVG Output", set "Path string format" to "Absolute". Then select all paths, and go to "Path" and click "Reverse" (This forces inkscape to rewrite the paths) and save as plain SVG.
Attach the pen at the correct height (callibration)
In order to callibrate the height of the pen I've created a small gcode file which just puts the head in the left bottom and moves the head 2mm above the bed. This will be the drawing height (Z).
Put a paper sheet on the bed, and clamp it to the bed using magnets. Run the
CALLIBRATE.gcode file and attach the pen such that it just touches the paper.
After callibration run
PEN_UP.gcode afterwards to lift the pen back up.
Convert the SVG to GCODE
In order to just plot the contour lines (strokes) present in the svg use:
svgto3dprintplot example.svg example_outline.gcode --stroke
Send the generated gcode file to your printer and enjoy!
By adding the
--fill flag, shapes will be filled with horizontal lines.
svgto3dprintplot example.svg example_outline.gcode --fill
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Hashes for plotting3dprinter-1.12-py3-none-any.whl