From 05b0bf5988317d7cd496a5f3c5d05dc3b760d751 Mon Sep 17 00:00:00 2001 From: Ghostkeeper Date: Mon, 11 May 2020 18:34:41 +0200 Subject: [PATCH] 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. --- .../scripts/PauseAtHeight.py | 40 +++++++++---------- 1 file changed, 19 insertions(+), 21 deletions(-) diff --git a/plugins/PostProcessingPlugin/scripts/PauseAtHeight.py b/plugins/PostProcessingPlugin/scripts/PauseAtHeight.py index 1ba8b8213b..8507565ef3 100644 --- a/plugins/PostProcessingPlugin/scripts/PauseAtHeight.py +++ b/plugins/PostProcessingPlugin/scripts/PauseAtHeight.py @@ -108,13 +108,12 @@ class PauseAtHeight(Script): "type": "float", "default_value": 3.3333 }, - "redo_layers": + "redo_layer": { - "label": "Redo Layers", - "description": "Redo a number of previous layers after a pause to increases adhesion.", - "unit": "layers", - "type": "int", - "default_value": 0 + "label": "Redo Layer", + "description": "Redo the last layer before the pause, to get the filament flowing again after having oozed a bit during the pause.", + "type": "bool", + "default_value": false }, "standby_temperature": { @@ -160,7 +159,7 @@ class PauseAtHeight(Script): park_x = self.getSettingValueByKey("head_park_x") park_y = self.getSettingValueByKey("head_park_y") layers_started = False - redo_layers = self.getSettingValueByKey("redo_layers") + redo_layer = self.getSettingValueByKey("redo_layer") 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") @@ -264,24 +263,23 @@ class PauseAtHeight(Script): if current_e >= 0: break - # include a number of previous layers - for i in range(1, redo_layers + 1): - prev_layer = data[index - i] + # Maybe redo the last layer. + if redo_layer: + prev_layer = data[index - 1] layer = prev_layer + layer # 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 - if i == redo_layers: - # Get X and Y from the next layer (better position for - # the nozzle) - x, y = self.getNextXY(layer) - prev_lines = prev_layer.split("\n") - for lin in prev_lines: - new_e = self.getValue(lin, "E", current_e) - if new_e != current_e: - current_e = new_e - break + # Get X and Y from the next layer (better position for + # the nozzle) + x, y = self.getNextXY(layer) + prev_lines = prev_layer.split("\n") + for lin in prev_lines: + new_e = self.getValue(lin, "E", current_e) + if new_e != current_e: + current_e = new_e + break prepend_gcode = ";TYPE:CUSTOM\n" prepend_gcode += ";added code by post processing\n"