Skip to content

Commit 6457a65

Browse files
authored
Merge pull request #13 from abey79/feature-layer-id
Add support for layer IDs
2 parents b9bce45 + 3668918 commit 6457a65

3 files changed

Lines changed: 13 additions & 13 deletions

File tree

README.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ Vpype plugin to generate gcode and other text output.
33
See: https://github.com/abey79/vpype
44

55

6-
Gcode vpype plugin. Write gcode files for the vpype pipeline. The output format can be customized by the user heavily to an extend that you can also output non gcode ascii text files.
6+
Gcode vpype plugin. Write gcode files for the vpype pipeline. The output format can be customized by the user heavily to an extent that you can also output non gcode ascii text files.
77

88
* `gwrite` write geometries as gcode to a file
99

@@ -81,13 +81,13 @@ These parameters define the transformation between *vpype*'s and the target's co
8181
- `offset_y`: Apply an offset to the Y axis. This offset is expressed in the unit defined by `unit`.
8282

8383
### Output Format
84-
All of the options below default to an empty text which means no output is generated. However, if `segment_first` or `segment_last` is omitted the code from `segment` is used. If there is only one segment. `segment_first` takes priority over `segment_last`.
85-
- `document_start`: Output to be generated at the start of the file as a document_start
86-
- `document_end`: Output to be generated at the end of the file as a document_end
87-
- `layer_start`: Output to be generated before a layer is started
84+
All of the options below default to an empty text which means no output is generated. However, if `segment_first` or `segment_last` is omitted the code from `segment` is used. If there is only one segment, `segment_first` takes priority over `segment_last`.
85+
- `document_start`: Output to be generated at the start of the file as a document_start.
86+
- `document_end`: Output to be generated at the end of the file as a document_end.
87+
- `layer_start`: Output to be generated before a layer is started.
8888
- `layer_end`: Output to be generated after a layer is finished.
8989
- `layer_join`: Output to be generated between two layers.
90-
- `line_start`: Output to be generated before a line is started
90+
- `line_start`: Output to be generated before a line is started.
9191
- `line_end`: Output to be generated after a line is finished.
9292
- `line_join`: Output to be generated between two lines.
9393
- `segment_first`: Output to be generated at the first coordinate pair.
@@ -97,8 +97,8 @@ All of the options below default to an empty text which means no output is gener
9797
### Segment formatting
9898
`gwrite` uses `.format()` encoding which means that data elements must be encapsulated in `{}` brackets. This provides a particular syntax token which differs from between elements.
9999
For example every element except `layer_join` and `segment_join` accepts the value of `index`. You would encode that in the text as `{index:d}` the d denotes an integer value. If you need to have a `{` value in your text you would encode that as `{{` likewise you would encode a `}` as `}}`.
100-
- `layer_start`: Accepts `index` the current layer number.
101-
- `layer_end`: Accepts `index` the current layer number.
100+
- `layer_start`: Accepts `index` the current layer number and `layer_id` as vpype layer ID.
101+
- `layer_end`: Accepts `index` the current layer number and `layer_id` as vpype layer ID.
102102
- `line_start`: Accepts `index` the current line number.
103103
- `line_end`: Accepts `index` the current line number.
104104

setup.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
from setuptools import setup
22

3-
43
with open("README.md") as f:
54
readme = f.read()
65

@@ -18,7 +17,7 @@
1817
"Programming Language :: Python :: 3.6",
1918
"Programming Language :: Python :: 3.7",
2019
"License :: OSI Approved :: MIT License",
21-
"Operating System :: OS Independent"
20+
"Operating System :: OS Independent",
2221
),
2322
include_package_data=True,
2423
install_requires=[

vpype_gcode/gwrite.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,9 +82,10 @@ def gwrite(document: vp.Document, output: typing.TextIO, profile: str):
8282
xx = 0
8383
yy = 0
8484
lastlayer_index = len(document.layers.values()) - 1
85-
for layer_index, layer in enumerate(document.layers.values()):
85+
for layer_index, layer_id in enumerate(document.layers):
86+
layer = document.layers[layer_id]
8687
if layer_start is not None:
87-
output.write(layer_start.format(index=layer_index))
88+
output.write(layer_start.format(index=layer_index, layer_id=layer_id))
8889
lastlines_index = len(layer) - 1
8990
for lines_index, line in enumerate(layer):
9091
if line_start is not None:
@@ -130,7 +131,7 @@ def gwrite(document: vp.Document, output: typing.TextIO, profile: str):
130131
if line_join is not None and lines_index != lastlines_index:
131132
output.write(line_join)
132133
if layer_end is not None:
133-
output.write(layer_end.format(index=layer_index))
134+
output.write(layer_end.format(index=layer_index, layer_id=layer_id))
134135
if layer_join is not None and layer_index != lastlayer_index:
135136
output.write(layer_join)
136137
if document_end is not None:

0 commit comments

Comments
 (0)