BQ_PauseAtHeight.py 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. from ..Script import Script
  2. class BQ_PauseAtHeight(Script):
  3. def __init__(self):
  4. super().__init__()
  5. def getSettingDataString(self):
  6. return """{
  7. "name":"Pause at height (BQ Printers)",
  8. "key": "BQ_PauseAtHeight",
  9. "metadata":{},
  10. "version": 2,
  11. "settings":
  12. {
  13. "pause_height":
  14. {
  15. "label": "Pause height",
  16. "description": "At what height should the pause occur",
  17. "unit": "mm",
  18. "type": "float",
  19. "default_value": 5.0
  20. }
  21. }
  22. }"""
  23. def execute(self, data):
  24. x = 0.
  25. y = 0.
  26. current_z = 0.
  27. pause_z = self.getSettingValueByKey("pause_height")
  28. for layer in data:
  29. lines = layer.split("\n")
  30. for line in lines:
  31. if self.getValue(line, 'G') == 1 or self.getValue(line, 'G') == 0:
  32. current_z = self.getValue(line, 'Z')
  33. if current_z != None:
  34. if current_z >= pause_z:
  35. prepend_gcode = ";TYPE:CUSTOM\n"
  36. prepend_gcode += "; -- Pause at height (%.2f mm) --\n" % pause_z
  37. # Insert Pause gcode
  38. prepend_gcode += "M25 ; Pauses the print and waits for the user to resume it\n"
  39. index = data.index(layer)
  40. layer = prepend_gcode + layer
  41. data[index] = layer # Override the data of this layer with the modified data
  42. return data
  43. break
  44. return data