fragmuffin / pygcode

GCODE Parser for Python
GNU General Public License v3.0
123 stars 38 forks source link

Dialects and floating-point precision #25

Open bwllc opened 4 years ago

bwllc commented 4 years ago

Thanks for this useful project!

I am working with GCode files which specify measurements in inches to 6 decimal places (and yes, this level of precision can matter on professional tools). The default linuxcnc dialect in pygcode appears to be parsing my files without difficulty. However, I noticed that all numbers were being rounded to 3 decimal places. The rounding is performed on line 33 of https://github.com/fragmuffin/pygcode/blob/master/src/pygcode/dialects/linuxcnc.py:

CLEAN_FLOAT = lambda v: "{0:g}".format(round(v, 3))

To proceed with my current project, I will simply modify my local copy of pygcode to round to 6 decimal places. However, I wonder whether I should register another dialect instead, perhaps I could call it "precise". The dialects section of pygcode appears to be incomplete. I'd like to start a discussion about what the author's intentions are for pygcode dialects, and how best to use them.

petaflot commented 3 months ago

see https://github.com/petaflot/pygcode ; you are welcome to make a pull request