Use firmware retraction and temperature control settings

Instead of deriving this from the g-code flavour, just use the actual settings that are made to control these two properties.

Contributes to issue CURA-5491.
This commit is contained in:
Ghostkeeper 2018-07-09 09:27:11 +02:00
parent b67339c3bf
commit 41857338cb
No known key found for this signature in database
GPG key ID: 5252B696FB5E7C7A

View file

@ -1,5 +1,9 @@
# Copyright (c) 2018 Ultimaker B.V.
# Cura is released under the terms of the LGPLv3 or higher.
from ..Script import Script
# from cura.Settings.ExtruderManager import ExtruderManager
from UM.Application import Application #To get the current printer's settings.
class PauseAtHeight(Script):
def __init__(self):
@ -136,9 +140,10 @@ class PauseAtHeight(Script):
layers_started = False
redo_layers = self.getSettingValueByKey("redo_layers")
standby_temperature = self.getSettingValueByKey("standby_temperature")
firmware_retract = Application.getInstance().getGlobalContainerStack().getProperty("machine_firmware_retract", "value")
control_temperatures = Application.getInstance().getGlobalContainerStack().getProperty("machine_nozzle_temp_enabled", "value")
is_griffin = False
is_ultigcode = False
# T = ExtruderManager.getInstance().getActiveExtruderStack().getProperty("material_print_temperature", "value")
@ -158,8 +163,6 @@ class PauseAtHeight(Script):
for line in lines:
if ";FLAVOR:Griffin" in line:
is_griffin = True
if ";FLAVOR:UltiGCode" in line:
is_ultigcode = True
# Fist positive layer reached
if ";LAYER:0" in line:
layers_started = True
@ -263,8 +266,8 @@ class PauseAtHeight(Script):
# Retraction
prepend_gcode += self.putValue(M = 83) + "\n"
if retraction_amount != 0:
if is_ultigcode:
prepend_gcode += self.putValue(G = 10) + "; retract for ultigcode\n"
if firmware_retract:
prepend_gcode += self.putValue(G = 10)
else:
prepend_gcode += self.putValue(G = 1, E = -retraction_amount, F = retraction_speed * 60) + "\n"
@ -277,7 +280,7 @@ class PauseAtHeight(Script):
if current_z < 15:
prepend_gcode += self.putValue(G = 1, Z = 15, F = 300) + "\n"
if not is_ultigcode: # We don't know about what temperatures are used in ultigcode, so do not touch
if control_temperatures:
# Set extruder standby temperature
prepend_gcode += self.putValue(M = 104, S = standby_temperature) + "; standby temperature\n"
@ -285,7 +288,7 @@ class PauseAtHeight(Script):
prepend_gcode += self.putValue(M = 0) + ";Do the actual pause\n"
if not is_griffin:
if not is_ultigcode: # will be 0 for ultigcode
if control_temperatures:
# Set extruder resume temperature
prepend_gcode += self.putValue(M = 109, S = int(target_temperature.get(current_t, 0))) + "; resume temperature\n"
@ -306,8 +309,8 @@ class PauseAtHeight(Script):
prepend_gcode += self.putValue(G = 1, Z = current_z + 1, F = 300) + "\n"
prepend_gcode += self.putValue(G = 1, X = x, Y = y, F = 9000) + "\n"
if retraction_amount != 0:
if is_ultigcode:
prepend_gcode += self.putValue(G = 11) + "; unretract for ultigcode\n"
if firmware_retract:
prepend_gcode += self.putValue(G = 11)
else:
prepend_gcode += self.putValue(G = 1, E = retraction_amount, F = retraction_speed * 60) + "\n"
prepend_gcode += self.putValue(G = 1, F = 9000) + "\n"