From 7a3aa87232cb2ca332dd0886ddabce858cfa8515 Mon Sep 17 00:00:00 2001 From: Michael Sims Date: Fri, 9 Sep 2022 15:44:48 -0700 Subject: [PATCH 1/3] Added ability to have multiple gcode commands before and after pausing print job --- .gitignore | 1 + plugins/PostProcessingPlugin/scripts/PauseAtHeight.py | 10 +++++----- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/.gitignore b/.gitignore index 26fe1ccf4a..4c3dd810e8 100644 --- a/.gitignore +++ b/.gitignore @@ -99,3 +99,4 @@ conanbuildinfo.txt graph_info.json Ultimaker-Cura.spec .run/ +/cmake-build-debug/ diff --git a/plugins/PostProcessingPlugin/scripts/PauseAtHeight.py b/plugins/PostProcessingPlugin/scripts/PauseAtHeight.py index 5923a53adf..916eaa2865 100644 --- a/plugins/PostProcessingPlugin/scripts/PauseAtHeight.py +++ b/plugins/PostProcessingPlugin/scripts/PauseAtHeight.py @@ -2,7 +2,7 @@ # Cura is released under the terms of the LGPLv3 or higher. from ..Script import Script - +import re from UM.Application import Application #To get the current printer's settings. from UM.Logger import Logger @@ -195,14 +195,14 @@ class PauseAtHeight(Script): "custom_gcode_before_pause": { "label": "G-code Before Pause", - "description": "Any custom g-code to run before the pause, for example, M300 S440 P200 to beep.", + "description": "Any custom g-code to run before the pause, for example, M300 S440 P200 to beep. Separate multiple commands with a comma.", "type": "str", "default_value": "" }, "custom_gcode_after_pause": { "label": "G-code After Pause", - "description": "Any custom g-code to run after the pause, for example, M300 S440 P200 to beep.", + "description": "Any custom g-code to run after the pause, for example, M300 S440 P200 to beep. Separate multiple commands with a comma.", "type": "str", "default_value": "" } @@ -258,8 +258,8 @@ class PauseAtHeight(Script): control_temperatures = Application.getInstance().getGlobalContainerStack().getProperty("machine_nozzle_temp_enabled", "value") initial_layer_height = Application.getInstance().getGlobalContainerStack().getProperty("layer_height_0", "value") display_text = self.getSettingValueByKey("display_text") - gcode_before = self.getSettingValueByKey("custom_gcode_before_pause") - gcode_after = self.getSettingValueByKey("custom_gcode_after_pause") + gcode_before = re.sub("\\s*,\\s*", "\n", self.getSettingValueByKey("custom_gcode_before_pause")) + gcode_after = re.sub("\\s*,\\s*", "\n", self.getSettingValueByKey("custom_gcode_after_pause")) pause_method = self.getSettingValueByKey("pause_method") pause_command = { From 883a3039e514b669ac9e66a917e55a5d5d6c53c0 Mon Sep 17 00:00:00 2001 From: Remco Burema Date: Wed, 25 Jan 2023 17:48:36 +0100 Subject: [PATCH 2/3] Remove old 'newline' solution. Will be fixed in the next commit(s). In retrospect, using ';' for the newline seperation was a bit daft, given that comments also start with that. done as part of CURA-9822 --- plugins/PostProcessingPlugin/scripts/PauseAtHeight.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/PostProcessingPlugin/scripts/PauseAtHeight.py b/plugins/PostProcessingPlugin/scripts/PauseAtHeight.py index c6c6543244..74a4b78eed 100644 --- a/plugins/PostProcessingPlugin/scripts/PauseAtHeight.py +++ b/plugins/PostProcessingPlugin/scripts/PauseAtHeight.py @@ -477,14 +477,14 @@ class PauseAtHeight(Script): # Set a custom GCODE section before pause if gcode_before: - prepend_gcode += gcode_before.replace(";","\n") + "\n" + prepend_gcode += gcode_before + "\n" # Wait till the user continues printing prepend_gcode += pause_command + " ; Do the actual pause\n" # Set a custom GCODE section after pause if gcode_after: - prepend_gcode += gcode_after.replace(";","\n") + "\n" + prepend_gcode += gcode_after + "\n" if pause_method == "repetier": #Push the filament back, From 725d1026ddeee535c4b19abd983228378fb88181 Mon Sep 17 00:00:00 2001 From: Greg Valiant <> Date: Thu, 26 Jan 2023 13:15:09 +0100 Subject: [PATCH 3/3] Revised PauseAtHeight.py. The changes are: For non-Repetier and non-Ultimaker printers - Move the prime extrusion so it occurs while the print head is still in the parked position so the blob doesn't happen over the print (GitHub #13584 and #11471 for reference). Add a user option to use M104 or M109 for the resume temperature to avoid an unnecessary delay if the resume temperature is the same as the standby temperature. committed as part of CURA-9822 --- .../scripts/PauseAtHeight.py | 45 ++++++++++++------- 1 file changed, 30 insertions(+), 15 deletions(-) diff --git a/plugins/PostProcessingPlugin/scripts/PauseAtHeight.py b/plugins/PostProcessingPlugin/scripts/PauseAtHeight.py index 82b7ba1359..7f8d1d118a 100644 --- a/plugins/PostProcessingPlugin/scripts/PauseAtHeight.py +++ b/plugins/PostProcessingPlugin/scripts/PauseAtHeight.py @@ -1,6 +1,10 @@ -# Copyright (c) 2021 Ultimaker B.V. +# Copyright (c) 2023 UltiMaker # Cura is released under the terms of the LGPLv3 or higher. +# Revised by GregValiant 10-17-2022 +# Changed "extrude" line to before the nozzle moves back to the print (if not Repetier or Griffin). +# Add M104 option for Resume temperature + from ..Script import Script import re from UM.Application import Application #To get the current printer's settings. @@ -42,7 +46,7 @@ class PauseAtHeight(Script): "pause_layer": { "label": "Pause Layer", - "description": "At what layer should the pause occur?", + "description": "Enter the Number of the LAST layer you want to finish prior to the pause (from the Cura preview).", "type": "int", "value": "math.floor((pause_height - 0.27) / 0.1) + 1", "minimum_value": "0", @@ -156,6 +160,14 @@ class PauseAtHeight(Script): "type": "bool", "default_value": false }, + "standby_wait_for_temperature_enabled": + { + "label": "Use M109 for standby temperature? (M104 when false)", + "description": "Wait for hot end after Resume? (If your standby temperature is lower than the Printing temperature CHECK and use M109", + "type": "bool", + "default_value": true, + "enabled": "pause_method not in [\\\"griffin\\\", \\\"repetier\\\"]" + }, "standby_temperature": { "label": "Standby Temperature", @@ -220,14 +232,14 @@ class PauseAtHeight(Script): "custom_gcode_before_pause": { "label": "G-code Before Pause", - "description": "Any custom g-code to run before the pause, for example, M300 S440 P200 to beep. Separate multiple commands with a comma.", + "description": "Custom g-code to run before the pause. EX: M300 to beep. Use a comma to separate multiple commands. EX: M400,M300,M117 Pause", "type": "str", "default_value": "" }, "custom_gcode_after_pause": { "label": "G-code After Pause", - "description": "Any custom g-code to run after the pause, for example, M300 S440 P200 to beep. Separate multiple commands with a comma.", + "description": "Custom g-code to run after the pause. Use a comma to separate multiple commands. EX: M204 X8 Y8,M106 S0,M117 Resume", "type": "str", "default_value": "" } @@ -279,6 +291,7 @@ class PauseAtHeight(Script): move_z = self.getSettingValueByKey("head_move_z") layers_started = False redo_layer = self.getSettingValueByKey("redo_layer") + standby_wait_for_temperature_enabled = self.getSettingValueByKey("standby_wait_for_temperature_enabled") 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") @@ -530,19 +543,23 @@ class PauseAtHeight(Script): elif pause_method != "griffin": if control_temperatures: # Set extruder resume temperature - prepend_gcode += self.putValue(M = 109, S = int(target_temperature.get(current_t, 0))) + " ; resume temperature\n" + if standby_wait_for_temperature_enabled: + WFT_numeric = 109 + Temp_resume_Text = " ; WAIT for resume temperature\n" + else: + WFT_numeric = 104 + Temp_resume_Text = " ; resume temperature\n" + + prepend_gcode += self.putValue(M=WFT_numeric, + S=int(target_temperature.get(current_t, 0))) + Temp_resume_Text if extrude_amount != 0: # Need to prime after the pause. # Push the filament back. - if retraction_amount != 0: - prepend_gcode += self.putValue(G = 1, E = retraction_amount, F = retraction_speed * 60) + "\n" + if extrude_speed == 0: + extrude_speed = 25 - # Prime the material. - prepend_gcode += self.putValue(G = 1, E = extrude_amount, F = extrude_speed * 60) + "; Extra extrude after the unpause\n" - - # And retract again to make the movements back to the starting position. - if retraction_amount != 0: - prepend_gcode += self.putValue(G = 1, E = -retraction_amount, F = retraction_speed * 60) + "\n" + if extrude_amount != 0: + prepend_gcode += self.putValue(G=1, E=extrude_amount, F=extrude_speed * 60) + "\n" # Move the head back if park_enabled: @@ -556,8 +573,6 @@ class PauseAtHeight(Script): retraction_count = 1 if control_temperatures else 3 #Retract more if we don't control the temperature. for i in range(retraction_count): prepend_gcode += self.putValue(G = 11) + "\n" - else: - prepend_gcode += self.putValue(G = 1, E = retraction_amount, F = retraction_speed * 60) + "\n" if current_extrusion_f != 0: prepend_gcode += self.putValue(G = 1, F = current_extrusion_f) + " ; restore extrusion feedrate\n"