Skip to content

Commit 1ff5b98

Browse files
committed
Merge remote-tracking branch 'origin/main'
2 parents d6026a8 + 1ac3f33 commit 1ff5b98

File tree

4 files changed

+229
-151
lines changed

4 files changed

+229
-151
lines changed

README.md

Lines changed: 75 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,11 @@ All of the options below default to an empty text which means no output is gener
111111
### Segment formatting
112112
`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.
113113
For example every element 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 `}}`.
114-
- `layer_start`, `layer_end` and `layer_join`: Accepts `x`, `y`, `ix`, `iy`, `index`, `index1`, `layer_index`, `layer_index1`, `layer_id`, and `filename`.
114+
115+
- `document_start` and `document_end` accept the following:
116+
- `filename` file name of the file being saved
117+
118+
- `layer_start`, `layer_end` and `layer_join` accept the following:
115119
- `x` the last_x position before this layer, this is 0 for the first layer
116120
- `y` the last_y position before this layer, this is 0 for the first layer
117121
- `ix` the last integer x location before this layer, this is 0 for the first layer.
@@ -122,7 +126,8 @@ For example every element accepts the value of `index`. You would encode that in
122126
- `layer_index1` the current layer number starting from 1
123127
- `layer_id` as vpype layer ID.
124128
- `filename` file name of the file being saved
125-
- `line_start`, `line_end` and `line_join`: Accepts `x`, `y`, `ix`, `iy`, `index`, `index1`, `lines_index`, `lines_index1`, `layer_index`, `layer_index1`, `layer_id`, and `filename`.
129+
130+
- `line_start`, `line_end` and `line_join`accept the following:
126131
- `x` the last_x position before this line, this is 0 for the first line of the first layer
127132
- `y` the last_y position before this line, this is 0 for the first line of the first layer
128133
- `ix` the last integer x location before this layer, this is 0 for the first layer.
@@ -136,36 +141,80 @@ For example every element accepts the value of `index`. You would encode that in
136141
- `layer_id` values for the current vpype layer ID that contains this line
137142
- `filename` file name of the file being saved
138143

139-
The segments (`segment_first`, `segment`, `segment_last`) accept a lot of values that may be useful statistics for various formats:
140-
* `index`: index of the particular coordinate pair. eg `{index:d}`
141-
* `x` absolute position x in floating point number. eg `{x:.4f}`
142-
* `y` absolute position y in floating point number. eg `{y:g}`
143-
* `dx` relative position x in floating point number. eg `{dx:f}`
144-
* `dy` relative position y in floating point number. eg `{dy:.2f}`
145-
* `_x` negated absolute position x in floating point number. eg `{_x:.4f}`
146-
* `_y` negated absolute position y in floating point number. eg `{_y:g}`
147-
* `_dx` negated relative position x in floating point number. eg `{_dx:f}`
148-
* `_dy` negated relative position y in floating point number. eg `{_dy:.2f}`
149-
* `ix` absolute position x in integer number. eg `{ix:d}`
150-
* `iy` absolute position y in integer number. eg `{iy:d}`
151-
* `idx` relative position x in integer number. eg `{idx:d}`
152-
* `idy` relative position y in integer number. eg `{idy:d}`
153-
* `index` same as `segment_index`
154-
* `index1` same as `segment_index1`
155-
* `segment_index` the current segment within this line starting from 0
156-
* `segment_index1` the current segment within this line starting from 1
157-
* `line_index` the current line index within this layer starting from 0
158-
* `line_index1` the current line index within this layer number starting from 1
159-
* `layer_index` the current layer index starting from 0
160-
* `layer_index1` the current layer number starting from 1
161-
* `layer_id` values for the current vpype layer ID that contains this line
162-
* `filename` file name of the file being saved
144+
- `segment_first`, `segment`, `segment_last` accept the following:
145+
* `index`: index of the particular coordinate pair. eg `{index:d}`
146+
* `x` absolute position x in floating point number. eg `{x:.4f}`
147+
* `y` absolute position y in floating point number. eg `{y:g}`
148+
* `dx` relative position x in floating point number. eg `{dx:f}`
149+
* `dy` relative position y in floating point number. eg `{dy:.2f}`
150+
* `_x` negated absolute position x in floating point number. eg `{_x:.4f}`
151+
* `_y` negated absolute position y in floating point number. eg `{_y:g}`
152+
* `_dx` negated relative position x in floating point number. eg `{_dx:f}`
153+
* `_dy` negated relative position y in floating point number. eg `{_dy:.2f}`
154+
* `ix` absolute position x in integer number. eg `{ix:d}`
155+
* `iy` absolute position y in integer number. eg `{iy:d}`
156+
* `idx` relative position x in integer number. eg `{idx:d}`
157+
* `idy` relative position y in integer number. eg `{idy:d}`
158+
* `index` same as `segment_index`
159+
* `index1` same as `segment_index1`
160+
* `segment_index` the current segment within this line starting from 0
161+
* `segment_index1` the current segment within this line starting from 1
162+
* `line_index` the current line index within this layer starting from 0
163+
* `line_index1` the current line index within this layer number starting from 1
164+
* `layer_index` the current layer index starting from 0
165+
* `layer_index1` the current layer number starting from 1
166+
* `layer_id` values for the current vpype layer ID that contains this line
167+
* `filename` file name of the file being saved
163168

164169
#### Notes
165170
* `idx` and `idy` are properly guarded against compounding fractional rounding errors. Moving 0.1 units 1000 times results in a location 100 units away and not zero.
166171
* `line_join` occurs after `line_end` but only appears *between* lines, it does not occur after the last line.
167172
* `layer_join` occurs after `layer_end` but only appears *between* layers, it does not occur after the last layer.
168173

174+
### Using properties
175+
176+
In addition to the variables described in the previous section, any existing [property](https://vpype.readthedocs.io/en/latest/fundamentals.html#properties) may be used for substitution. For example, the layer color is stored as a property named `vp_color` and can be added to the profile with the pattern `{vp_color}`. Since this is a layer property, it would be available for all options but `document_start` and `document_end`, for which no current layer is defined. Global properties are available to all options.
177+
178+
There is no guarantee that a given property is defined upon export time, even system properties such as `vp_color`. If a property used in the selected profile doesn't exist, an error will be generated. To avoid this, a default value for the property must be provided, which can be achieved in two ways: in the config file or using the `--default` option.
179+
180+
This is an example of profile configuration which includes a default value for the `vp_color` and `vp_pen_width` properties:
181+
182+
```toml
183+
[gwrite.summary]
184+
layer_start = "layer {layer_index1:d} (color = {vp_color}, pen_width = {vp_pen_width:0.2f})\n"
185+
layer_join = "\n"
186+
line_start = "line {index1} segment count: "
187+
segment_last = "{index:d}\n"
188+
default_values = {vp_color = "undefined", vp_pen_width = 0.1}
189+
```
190+
191+
Here is an example of use:
192+
193+
```
194+
$ vpype rect 0 0 10cm 10cm color red random --layer 2 penwidth --layer 2 0.5mm gwrite -p summary -
195+
layer 1 (color = #ff0000, pen_width = 0.10)
196+
line 1 segment count: 4
197+
198+
layer 2 (color = undefined, pen_width = 1.89)
199+
line 1 segment count: 1
200+
line 2 segment count: 1
201+
line 3 segment count: 1
202+
line 4 segment count: 1
203+
line 5 segment count: 1
204+
line 6 segment count: 1
205+
line 7 segment count: 1
206+
line 8 segment count: 1
207+
line 9 segment count: 1
208+
line 10 segment count: 1
209+
```
210+
211+
Alternatively, default values for string-based variable may be provided using the command line using the `--default` option:
212+
213+
```
214+
$ vpype [...] gwrite -p summary --default vp_color undefined output.txt
215+
```
216+
217+
169218
### Information Control
170219
- `info`: prints text to the console after file is written to inform the user of said information
171220

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
click
2-
vpype>=1.9,<2.0
2+
vpype>=1.10,<2.0
33
numpy

setup.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,9 @@
1414
url="https://github.com/plottertools/vpype-gcode/",
1515
packages=["vpype_gcode"],
1616
classifiers=[
17-
"Programming Language :: Python :: 3.6",
18-
"Programming Language :: Python :: 3.7",
1917
"Programming Language :: Python :: 3.8",
2018
"Programming Language :: Python :: 3.9",
19+
"Programming Language :: Python :: 3.10",
2120
"Environment :: Console",
2221
"Topic :: Artistic Software",
2322
"Topic :: Multimedia :: Graphics",
@@ -27,7 +26,7 @@
2726
include_package_data=True,
2827
install_requires=[
2928
"click",
30-
"vpype>=1.9,<2.0",
29+
"vpype>=1.10,<2.0",
3130
"numpy",
3231
],
3332
entry_points="""

0 commit comments

Comments
 (0)