hpgl.py 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. from FlatCAMPostProc import *
  2. # for Roland Postprocessors it is mandatory for the postprocessor name (python file and class name, both of them must be
  3. # the same) to contain the following keyword, case-sensitive: 'Roland' without the quotes.
  4. class hpgl(FlatCAMPostProc):
  5. coordinate_format = "%.*f"
  6. def start_code(self, p):
  7. gcode = 'IN;'
  8. return gcode
  9. def startz_code(self, p):
  10. return ''
  11. def lift_code(self, p):
  12. gcode = 'PU;' + '\n'
  13. return gcode
  14. def down_code(self, p):
  15. gcode = 'PD;' + '\n'
  16. return gcode
  17. def toolchange_code(self, p):
  18. return 'SP%d;' % int(p.tool)
  19. def up_to_zero_code(self, p):
  20. return ''
  21. def position_code(self, p):
  22. units = str(p['units']).lower()
  23. # we work only with METRIC units because HPGL mention only metric units so if FlatCAM units are INCH we
  24. # transform them in METRIC
  25. if units == 'in':
  26. x = p.x * 25.4
  27. y = p.y * 25.4
  28. else:
  29. x = p.x
  30. y = p.y
  31. # we need to have the coordinates as multiples of 0.025mm
  32. x = round(x / 0.025) * 25 / 1000
  33. y = round(y / 0.025) * 25 / 1000
  34. return ('PA' + self.coordinate_format + ',' + self.coordinate_format + ';') % \
  35. (p.coords_decimals, x, p.coords_decimals, y)
  36. def rapid_code(self, p):
  37. return self.position_code(p).format(**p)
  38. def linear_code(self, p):
  39. return self.position_code(p).format(**p)
  40. def end_code(self, p):
  41. gcode = self.position_code(p).format(**p)
  42. return gcode
  43. def feedrate_code(self, p):
  44. return ''
  45. def z_feedrate_code(self, p):
  46. return ''
  47. def feedrate_rapid_code(self, p):
  48. return ''
  49. def spindle_code(self, p):
  50. return ''
  51. def dwell_code(self, p):
  52. return ''
  53. def spindle_stop_code(self,p):
  54. return ''