vpype gcode plugin
Project description
vpype-gcode
Vpype plugin for gcode See: https://github.com/abey79/vpype
Gcode vpype plugin. Write gcode files for the vpype pipeline.
gwrite
write gcode geometries to disk
Installing
$ pip install vpype-gcode
vpype gwrite --help
Options:
-v, --version TEXT version to write
-h, --header TEXT header to write
-m, --move TEXT move to write
-l, --line TEXT header to write
-b, --preblock TEXT preblock to write
-B, --postblock TEXT postblock to write
-c, --prelayer TEXT prelayer to write
-C, --postlayer TEXT postlayer to write
-h, --footer TEXT header to write
-u, --unit TEXT unit for coordinates (i.e. in or mm)
-x, --flip_x flip_x from native
-y, --flip_y flip_y from native
-r, --relative use relative coordinates
--help Show this message and exit.
Versions
'ninja':
{
'header': 'G20\nG17\nG90\n',
'move': 'M380\nG00 X%.4f Y%.4f\nM381\n',
'line': 'G01 X%.4f Y%.4f\n',
'footer': 'M2\n',
'unit': 'mm'
},
'gcode':
{
'header': 'G20\nG17\nG90\n',
'move': 'G00 X%.4f Y%.4f\n',
'line': 'G01 X%.4f Y%.4f\n',
'footer': 'M2\n',
'unit': 'mm'
},
'gcode_relative':
{
'header': 'G20\nG17\nG91\n',
'move': 'G00 X%.4f Y%.4f\n',
'line': 'G01 X%.4f Y%.4f\n',
'footer': 'M2\n',
'relative': True,
'unit': 'mm'
}
'csv':
{
'header': "#Operation, X-value, Y-value\n",
'move': "Move, %f, %f\n",
'line': "Line-to, %f, %f\n"
},
'json':
{
'header': '{\n',
'footer': '}\n',
'prelayer': '\t"Layer": {\n',
'preblock': '\t\t"Block": [\n',
'move': '\t\t{\n\t\t\t"X": %d,\n\t\t\t"Y": %d\n\t\t}',
'line': ',\n\t\t{\n\t\t\t"X": %d,\n\t\t\t"Y": %d\n\t\t}',
'postblock': '\n\t\t],\n',
'postlayer': '\t},\n',
}
Examples
Convert SVG -> GCode
vpype read butterfly.svg gwrite --version gcode butterfly.gcode
Loads up a svg and writes it in default gcode.
vpype begin grid -o 25 25 10 10 circle 0 0 100 end gwrite --version ninja -y --footer M99 test.gcode
Here we are creating a grid of circles then we are gwrite
in version ninja
with a flipped y-axis and a footer of M99 rather than our default footer in ninja
that is M2\n
Let's say our gcode is so different that it's an CSV file.
vpype begin grid -o 25 25 10 10 circle 0 0 100 end gwrite --header "#Operation, X-value, Y-value\n" --move "Move, %d, %d\n" --line "Line-to, %d, %d\n" test.csv
This produces:
#Operation, X-value, Y-value
Move, 26, 0
Line-to, 26, 0
Line-to, 26, -1
Line-to, 26, -2
Line-to, 26, -3
Line-to, 25, -4
Line-to, 25, -5
Line-to, 25, -6
...
Giving it a simplier example:
vpype rect 0 0 100 100 gwrite --header "#Operation, X-value, Y-value\n" --move "Move, %d, %d\n" --line "Line-to, %d, %d\n" test.csv
#Operation, X-value, Y-value
Move, 0, 0
Line-to, 0, 100
Line-to, 100, 100
Line-to, 100, 0
Line-to, 0, 0
This produces a plain text CSV file of the rectangle.
Now using versions we could have done --version csv
for this, but you can simply give the parts needed to perform your output.
Formatting
The gwrite command gives you access to write to a variety of formats that fit the given outline. We're writing generic ascii. Since gcode can have more flavors than a Baskin Robbinsâ„¢, it's best to simply draw broad strokes as to what ascii output should look like. Here we define the various elements without any regard to the gcode it will largely be producing.
<header>
<prelayer>
<preblock>
<move>
<line>
<line>
<line>
<line>
<postblock>
<preblock>
<move>
<line>
<line>
<line>
<line>
<postblock>
<preblock>
<move>
<line>
<line>
<line>
<line>
<postblock>
<postlayer>
<prelayer>
<preblock>
<move>
<line>
<line>
<line>
<line>
<postblock>
<preblock>
<move>
<line>
<line>
<line>
<line>
<postblock>
<preblock>
<move>
<line>
<line>
<line>
<line>
<postblock>
<postlayer>
<footer>
This is the secret sauce of gwrite, it writes generic ascii which can be themed as functional gcode.
For example if you write version json
:
'json':
{
'header': '{\n',
'footer': '}\n',
'prelayer': '\t"Layer": {\n',
'preblock': '\t\t"Block": [\n',
'move': '\t\t{\n\t\t\t"X": %d,\n\t\t\t"Y": %d\n\t\t}',
'line': ',\n\t\t{\n\t\t\t"X": %d,\n\t\t\t"Y": %d\n\t\t}',
'postblock': '\n\t\t],\n',
'postlayer': '\t},\n',
}
Sending our rectangle to Json:
vpype rect 0 0 100 100 gwrite --version json test.json
{
"Layer": {
"Block": [
{
"X": 0,
"Y": 0
},
{
"X": 0,
"Y": 100
},
{
"X": 100,
"Y": 100
},
{
"X": 100,
"Y": 0
},
{
"X": 0,
"Y": 0
}
],
},
}
Strictly speaking json shouldn't have the last 2 commas there, but it's for demonstration purposes.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for vpype_gcode-0.1.0-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c5f14e3fcf1f8202205043e9b710465bacf2fa39e1160155c017f238bbd18f74 |
|
MD5 | f1ae46f7f04aa7bc42b32e1af4874a57 |
|
BLAKE2b-256 | c5841e49840b8dd464c72d9db287737e0f1dfc6c08c7fbd22c817b9130cb9123 |