- when saving HPGL code it will be saved as a file with extension .plt

- the units mentioned in HPGL format are only METRIC therefore if FlatCAM units are in INCH they will be transform to METRIC
- the minimum unit in HPGL is 0.025mm therefore the coordinates are rounded to a multiple of 0.025mm
This commit is contained in:
Marius Stanciu
2019-01-20 04:11:34 +02:00
committed by Marius S
parent 7ea6ee4a85
commit b9a062a84e
3 changed files with 26 additions and 7 deletions

View File

@@ -6,8 +6,6 @@ from FlatCAMPostProc import *
class hpgl(FlatCAMPostProc):
coordinate_format = "%.*f"
feedrate_format = '%.1f'
feedrate_rapid_format = '%.1f'
def start_code(self, p):
gcode = 'IN;'
@@ -31,8 +29,23 @@ class hpgl(FlatCAMPostProc):
return ''
def position_code(self, p):
units = str(p['units']).lower()
# we work only with METRIC units because HPGL mention only metric units so if FlatCAM units are INCH we
# transform them in METRIC
if units == 'in':
x = p.x * 25.4
y = p.y * 25.4
else:
x = p.x
y = p.y
# we need to have the coordinates as multiples of 0.025mm
x = round(x / 0.025) * 25 / 1000
y = round(y / 0.025) * 25 / 1000
return ('PA' + self.coordinate_format + ',' + self.coordinate_format + ';') % \
(p.coords_decimals, p.x, p.coords_decimals, p.y)
(p.coords_decimals, x, p.coords_decimals, y)
def rapid_code(self, p):
return self.position_code(p).format(**p)