You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+62-9Lines changed: 62 additions & 9 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -67,6 +67,7 @@ G4 P0.5\n"""
67
67
document_end = """M5
68
68
G00 X0.0000 Y0.0000
69
69
M2"""
70
+
invert_y = "True"
70
71
```
71
72
72
73
You can use the following options inside a profile. You only need to provide the options where you need to change the default. If you want a newline character in an option, you can either use escape sequences (`\n`) or you use TOML multi line strings wrapped in `""""`.
@@ -98,13 +99,33 @@ All of the options below default to an empty text which means no output is gener
98
99
99
100
### Segment formatting
100
101
`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.
101
-
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 `}}`.
102
-
-`layer_start`: Accepts `index` the current layer index starting from 0, `index1` the current layer number starting from 1, and `layer_id` as vpype layer ID.
103
-
-`layer_end`: Accepts `index` the current layer index starting from 0, `index1` the current layer number starting from 1, and `layer_id` as vpype layer ID.
104
-
-`line_start`: Accepts `index` the current line number starting from 0, `index1` the current line number starting from 1, and `layer_index`, `layer_index1`, and `layer_id` values for the current layer this line is within.
105
-
-`line_end`: Accepts `index` the current line number starting from 0, `index1` the current line number starting from 1, and `layer_index`, `layer_index1`, and `layer_id` values for the current layer this line is within.
102
+
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 `}}`.
103
+
-`layer_start`, `layer_end` and `layer_join`: Accepts `x`, `y`, `ix`, `iy`, `index`, `index1`, `layer_index`, `layer_index1`, `layer_id`, and `filename`.
104
+
-`x` the last_x position before this layer, this is 0 for the first layer
105
+
-`y` the last_y position before this layer, this is 0 for the first layer
106
+
-`ix` the last integer x location before this layer, this is 0 for the first layer.
107
+
-`iy` the last integer y location before this layer, this is 0 for the first layer.
108
+
-`index` same as `layer_index`
109
+
-`index1` same as `layer_index1`
110
+
-`layer_index` the current layer index starting from 0
111
+
-`layer_index1` the current layer number starting from 1
112
+
-`layer_id` as vpype layer ID.
113
+
-`filename` file name of the file being saved
114
+
-`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`.
115
+
-`x` the last_x position before this line, this is 0 for the first line of the first layer
116
+
-`y` the last_y position before this line, this is 0 for the first line of the first layer
117
+
-`ix` the last integer x location before this layer, this is 0 for the first layer.
118
+
-`iy` the last integer y location before this layer, this is 0 for the first layer.
119
+
-`index` same as `line_index`
120
+
-`index1` same as `line_index1`
121
+
-`line_index` the current line index within this layer starting from 0
122
+
-`line_index1` the current line index within this layer number starting from 1
123
+
-`layer_index` the current layer index starting from 0
124
+
-`layer_index1` the current layer number starting from 1
125
+
-`layer_id` values for the current vpype layer ID that contains this line
126
+
-`filename` file name of the file being saved
106
127
107
-
The segments accept a lot of values that may be useful statistics for various formats:
128
+
The segments (`segment_first`, `segment`, `segment_last`) accept a lot of values that may be useful statistics for various formats:
108
129
*`index`: index of the particular coordinate pair. eg `{index:d}`
109
130
*`x` absolute position x in floating point number. eg `{x:.4f}`
110
131
*`y` absolute position y in floating point number. eg `{y:g}`
@@ -118,11 +139,24 @@ The segments accept a lot of values that may be useful statistics for various fo
118
139
*`iy` absolute position y in integer number. eg `{iy:d}`
119
140
*`idx` relative position x in integer number. eg `{idx:d}`
120
141
*`idy` relative position y in integer number. eg `{idy:d}`
121
-
122
-
Note: `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.
142
+
*`index` same as `segment_index`
143
+
*`index1` same as `segment_index1`
144
+
*`segment_index` the current segment within this line starting from 0
145
+
*`segment_index1` the current segment within this line starting from 1
146
+
*`line_index` the current line index within this layer starting from 0
147
+
*`line_index1` the current line index within this layer number starting from 1
148
+
*`layer_index` the current layer index starting from 0
149
+
*`layer_index1` the current layer number starting from 1
150
+
*`layer_id` values for the current vpype layer ID that contains this line
151
+
*`filename` file name of the file being saved
152
+
153
+
#### Notes
154
+
*`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.
155
+
*`line_join` occurs after `line_end` but only appears *between* lines, it does not occur after the last line.
156
+
*`layer_join` occurs after `layer_end` but only appears *between* layers, it does not occur after the last layer.
123
157
124
158
### Information Control
125
-
-`info`: prints text after file is written to inform the user of said information
159
+
-`info`: prints text to the console after file is written to inform the user of said information
126
160
127
161
## Output structure
128
162
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.
@@ -137,6 +171,7 @@ The gwrite command gives you access to write to a variety of formats that fit th
137
171
<segment>
138
172
<segment_last>
139
173
<line_end>
174
+
<line_join>
140
175
<line_start>
141
176
<segment_first>
142
177
<segment>
@@ -145,6 +180,7 @@ The gwrite command gives you access to write to a variety of formats that fit th
145
180
<segment>
146
181
<segment_last>
147
182
<line_end>
183
+
<line_join>
148
184
<line_start>
149
185
<segment_first>
150
186
<segment>
@@ -154,6 +190,7 @@ The gwrite command gives you access to write to a variety of formats that fit th
154
190
<segment_last>
155
191
<line_end>
156
192
<layer_end>
193
+
<layer_join>
157
194
<layer_start>
158
195
<line_start>
159
196
<segment_first>
@@ -163,6 +200,7 @@ The gwrite command gives you access to write to a variety of formats that fit th
163
200
<segment>
164
201
<segment_last>
165
202
<line_end>
203
+
<line_join>
166
204
<line_start>
167
205
<segment_first>
168
206
<segment>
@@ -171,6 +209,7 @@ The gwrite command gives you access to write to a variety of formats that fit th
171
209
<segment>
172
210
<segment_last>
173
211
<line_end>
212
+
<line_join>
174
213
<line_start>
175
214
<segment_first>
176
215
<segment>
@@ -189,6 +228,20 @@ To prevent having to provide the profile on every invocation of the gcode plugin
189
228
default_profile = "gcode"
190
229
```
191
230
231
+
## Coordinate System
232
+
`Vpype-Gcode` uses the standard coordinate system of vpype which uses the SVG spec' system. The origin point is located in the upper-left hand corner. Positive y values are towards the bottom. If you wish to change the coordinate system you should use `invert_y` and `invert_x` equals `"True"` in your profile. This will mirror the work horizontally or vertically within the same euclidean space. For example the native Coordinate system of gcode is origin point in the bottom left. This requires that for gcode profiles be marked as `invert_y`.
233
+
234
+
```toml
235
+
[gwrite.gcode]
236
+
document_start = "G20\nG17\nG90\n"
237
+
segment_first = "G00 X{x:.4f} Y{y:.4f}\n"
238
+
segment = "G01 X{x:.4f} Y{y:.4f}\n"
239
+
document_end = "M2\n"
240
+
unit = "in"
241
+
invert_y = "True"
242
+
info= "This gcode profile is correctly inverted across the y-axis"
0 commit comments