plottertools / vpype-gcode

gcode extension for vpype
MIT License
35 stars 7 forks source link

Use `.format()` and keyword argument for string formatting and remove `relative` parameter #8

Closed abey79 closed 3 years ago

abey79 commented 3 years ago

For flexibility and easy of extension, I suggest using the following pattern for string formatting:

f.write(move.format(dx=dx, dy=dy, x=x, y=y)

Using this approach, all of the following configuration actually work as expected (not that they would be correct g-code):

move = "G00 {x:.4f} {y:.4f}\n"
move = "G00 {y:.4f} {x:.4f}\n"
move = "G00 {dx:.4f} {dy:.4f}\n"
move = "G00 {dy:.4f} {dx:.4f}\n"

Benefit:

Again, since this changes the configuration file format (user must use the {} notation), this change is best done early.

tatarize commented 3 years ago

This is certainly a solid request. I'll see if it ports across rather trivially, though I would assume it would.

tatarize commented 3 years ago

Completed in 0.4.0