vpype-gcode#
vpype and the vpype-gcode are powering the svg2plot.py script and used to optimize and convert SVG files into ready-to-plot gcode files.
Installation#
Note
Before starting make sure you have a running version of Python >= 3.8 installed. The following installation steps are from the vpype documentation.
virtual environment (recommended)#
python -m venv vpype_venv
source vpype_venv/bin/activate
pip install vpype
test#
vpype line 0mm 0mm 980mm 980mm line 0mm 980mm 980mm 0mm frame write -f svg -
<?xml version="1.0" encoding="utf-8" ?>
<svg xmlns="http://www.w3.org/2000/svg" xmlns:cc="http://creativecommons.org/ns#" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:ev="http://www.w3.org/2001/xml-events" xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" xmlns:xlink="http://www.w3.org/1999/xlink" baseProfile="tiny" height="98.0cm" version="1.2" viewBox="0 0 3703.937007874016 3703.937007874016" width="98.0cm">
<metadata>
<rdf:RDF>
<cc:Work>
<dc:format>image/svg+xml</dc:format>
<dc:source>vpype line 0mm 0mm 980mm 980mm line 0mm 980mm 980mm 0mm frame write -f svg -
</dc:source>
<dc:date>2021-10-06T13:01:37.559045</dc:date>
</cc:Work>
</rdf:RDF>
</metadata>
<defs/>
<g fill="none" id="layer1" inkscape:groupmode="layer" inkscape:label="1" stroke="#00f" style="display:inline">
<line x1="0.0" x2="3703.937" y1="0.0" y2="3703.937"/>
<line x1="0.0" x2="3703.937" y1="3703.937" y2="0.0"/>
<polygon points="0.0,0.0 0.0,3703.937 3703.937,3703.937 3703.937,0.0"/>
</g>
</svg>
To save the file, end the previous command with write output.svg.
Exit the virtual environment with the command deactivate.
vpype-gcode plug-in#
Necessary plugin to have g-code as an output option in the vpype command chain.
Follow the installation instructions here or just run the following command:
python -m pip install vpype-gcode
configuration#
Custom configuration in prefs.toml file in the current working
directory. This profile will generate gcode with penUP/penDOWN commands
as movements in Z. It is passed to vpype with --config.
cf. svg2plot repository
test#
activate the virtual environment
cd vpype_venv
source ./bin/activate
and run the following vpype command
:: sh
vpype –config prefs.toml line 0mm 0mm 980mm 980mm line 0mm 980mm 980mm 0mm frame gwrite -p step_motor -
$H (unlock by homing)
G21 (unit is mm)
G17 (work in XY plane)
G91 Z-10 (pen up)
G90 X0.0000 Y0.0000 (travel)
G91 Z+13 (pen down)
G90 (absolute position)
G01 X980.0000 Y980.0000 (draw)
G91 Z-10 (pen up)
G90 X0.0000 Y980.0000 (travel)
G91 Z+13 (pen down)
G90 (absolute position)
G01 X980.0000 Y0.0000 (draw)
G91 Z-10 (pen up)
G90 X0.0000 Y0.0000 (travel)
G91 Z+13 (pen down)
G90 (absolute position)
G01 X0.0000 Y980.0000 (draw)
G01 X980.0000 Y980.0000 (draw)
G01 X980.0000 Y0.0000 (draw)
G01 X0.0000 Y0.0000 (draw)
G91 Z-10 (pen up)
G90 X0 Y0 (travel)
M2 (end)
workflow#
1. layout and optimize SVG file for plotting.#
In the same location already containing the prefs.toml file, save a
test input.svg image and the below alice-plotter.vpy vpype
command
file
(a file containing a group of vpype commands).
alicelab/xy-plotter-docs/-/snippets/2184980.js
Run this command from the current directory:
vpype read input.svg -I alice-plotter.vpy``
In the directory should now appear a plot.svg file.
2. Separate its layers.#
Inkscape