Turn 'Redo Layers' into a boolean for at most 1 layer

We've deemed it irresponsible to redo multiple layers. This will dig the nozzle back down into the layers that were printed before the pause.

This doesn't include a version upgrade yet.

Contributes to issue CURA-7413.
This commit is contained in:
Ghostkeeper 2020-05-11 18:34:41 +02:00
parent 1946615fff
commit 05b0bf5988
No known key found for this signature in database
GPG key ID: D2A8871EE34EC59A

View file

@ -108,13 +108,12 @@ class PauseAtHeight(Script):
"type": "float", "type": "float",
"default_value": 3.3333 "default_value": 3.3333
}, },
"redo_layers": "redo_layer":
{ {
"label": "Redo Layers", "label": "Redo Layer",
"description": "Redo a number of previous layers after a pause to increases adhesion.", "description": "Redo the last layer before the pause, to get the filament flowing again after having oozed a bit during the pause.",
"unit": "layers", "type": "bool",
"type": "int", "default_value": false
"default_value": 0
}, },
"standby_temperature": "standby_temperature":
{ {
@ -160,7 +159,7 @@ class PauseAtHeight(Script):
park_x = self.getSettingValueByKey("head_park_x") park_x = self.getSettingValueByKey("head_park_x")
park_y = self.getSettingValueByKey("head_park_y") park_y = self.getSettingValueByKey("head_park_y")
layers_started = False layers_started = False
redo_layers = self.getSettingValueByKey("redo_layers") redo_layer = self.getSettingValueByKey("redo_layer")
standby_temperature = self.getSettingValueByKey("standby_temperature") standby_temperature = self.getSettingValueByKey("standby_temperature")
firmware_retract = Application.getInstance().getGlobalContainerStack().getProperty("machine_firmware_retract", "value") firmware_retract = Application.getInstance().getGlobalContainerStack().getProperty("machine_firmware_retract", "value")
control_temperatures = Application.getInstance().getGlobalContainerStack().getProperty("machine_nozzle_temp_enabled", "value") control_temperatures = Application.getInstance().getGlobalContainerStack().getProperty("machine_nozzle_temp_enabled", "value")
@ -264,24 +263,23 @@ class PauseAtHeight(Script):
if current_e >= 0: if current_e >= 0:
break break
# include a number of previous layers # Maybe redo the last layer.
for i in range(1, redo_layers + 1): if redo_layer:
prev_layer = data[index - i] prev_layer = data[index - 1]
layer = prev_layer + layer layer = prev_layer + layer
# Get extruder's absolute position at the # Get extruder's absolute position at the
# beginning of the first layer redone # beginning of the redone layer.
# see https://github.com/nallath/PostProcessingPlugin/issues/55 # see https://github.com/nallath/PostProcessingPlugin/issues/55
if i == redo_layers: # Get X and Y from the next layer (better position for
# Get X and Y from the next layer (better position for # the nozzle)
# the nozzle) x, y = self.getNextXY(layer)
x, y = self.getNextXY(layer) prev_lines = prev_layer.split("\n")
prev_lines = prev_layer.split("\n") for lin in prev_lines:
for lin in prev_lines: new_e = self.getValue(lin, "E", current_e)
new_e = self.getValue(lin, "E", current_e) if new_e != current_e:
if new_e != current_e: current_e = new_e
current_e = new_e break
break
prepend_gcode = ";TYPE:CUSTOM\n" prepend_gcode = ";TYPE:CUSTOM\n"
prepend_gcode += ";added code by post processing\n" prepend_gcode += ";added code by post processing\n"