From 3bb782fd5f0bb7bb05856634e5f80c6fd3ee47bc Mon Sep 17 00:00:00 2001 From: "Justin F. Hallett" Date: Fri, 5 Jul 2024 09:52:28 -0600 Subject: [PATCH] Add 3 New UI Settings - Add UI to set `machine_start_gcode_first` so that no gcode is adding infront of the start_gcode. - Add float input box to set `machine_extruder_change_duration` which added proper extruder change times to the estimated print time. - Add textbox to set `machine_extruder_prestart_code` to add gcodes that will run pre extruder change, things like heat up so we are at change before with pick up the next extruder. --- plugins/CuraEngineBackend/StartSliceJob.py | 1 + .../MachineSettingsExtruderTab.qml | 74 ++++++++++++++++--- .../MachineSettingsPrinterTab.qml | 15 ++++ resources/definitions/fdmextruder.def.json | 25 ++++++- resources/definitions/fdmprinter.def.json | 12 ++- 5 files changed, 115 insertions(+), 12 deletions(-) diff --git a/plugins/CuraEngineBackend/StartSliceJob.py b/plugins/CuraEngineBackend/StartSliceJob.py index 9caadbdff6..894c5669fc 100644 --- a/plugins/CuraEngineBackend/StartSliceJob.py +++ b/plugins/CuraEngineBackend/StartSliceJob.py @@ -518,6 +518,7 @@ class StartSliceJob(Job): # Replace the setting tokens in start and end g-code. extruder_nr = stack.getProperty("extruder_nr", "value") + settings["machine_extruder_prestart_code"] = self._expandGcodeTokens(settings["machine_extruder_prestart_code"], extruder_nr) settings["machine_extruder_start_code"] = self._expandGcodeTokens(settings["machine_extruder_start_code"], extruder_nr) settings["machine_extruder_end_code"] = self._expandGcodeTokens(settings["machine_extruder_end_code"], extruder_nr) diff --git a/plugins/MachineSettingsAction/MachineSettingsExtruderTab.qml b/plugins/MachineSettingsAction/MachineSettingsExtruderTab.qml index 5e1ddc2f3f..15b507480c 100644 --- a/plugins/MachineSettingsAction/MachineSettingsExtruderTab.qml +++ b/plugins/MachineSettingsAction/MachineSettingsExtruderTab.qml @@ -54,7 +54,7 @@ Item { anchors.top: parent.top anchors.left: parent.left - width: parent.width * 2 / 3 + width: parent.width / 2 spacing: base.columnSpacing @@ -139,6 +139,39 @@ Item decimals: 0 forceUpdateOnChangeFunction: forceUpdateFunction } + } + + + // ======================================= + // Right-side column "Nozzle Settings" + // ======================================= + Column + { + anchors.top: parent.top + anchors.right: parent.right + width: parent.width / 2 + + spacing: base.columnSpacing + + UM.Label // Title Label + { + text: catalog.i18nc("@title:label", " ") + font: UM.Theme.getFont("medium_bold") + } + + Cura.NumericTextFieldWithUnit + { + id: extruderChangeDurationFieldId + containerStackId: base.extruderStackId + settingKey: "machine_extruder_change_duration" + settingStoreIndex: propertyStoreIndex + labelText: catalog.i18nc("@label", "Extruder Change duration") + labelFont: base.labelFont + labelWidth: base.labelWidth + controlWidth: base.controlWidth + unitText: catalog.i18nc("@label", "s") + forceUpdateOnChangeFunction: forceUpdateFunction + } Cura.NumericTextFieldWithUnit { @@ -179,25 +212,46 @@ Item anchors.right: parent.right anchors.margins: UM.Theme.getSize("default_margin").width - Cura.GcodeTextArea // "Extruder Start G-code" + Column { anchors.top: parent.top - anchors.bottom: parent.bottom - anchors.bottomMargin: UM.Theme.getSize("default_margin").height anchors.left: parent.left - width: base.columnWidth - UM.Theme.getSize("default_margin").width + anchors.bottom: parent.bottom + width: parent.width / 2 - labelText: catalog.i18nc("@title:label", "Extruder Start G-code") - containerStackId: base.extruderStackId - settingKey: "machine_extruder_start_code" - settingStoreIndex: propertyStoreIndex + spacing: base.columnSpacing + + Cura.GcodeTextArea // "Extruder Prestart G-code" + { + anchors.top: parent.top + anchors.left: parent.left + height: (parent.height / 2) - UM.Theme.getSize("default_margin").height + width: base.columnWidth - UM.Theme.getSize("default_margin").width + + labelText: catalog.i18nc("@title:label", "Extruder Prestart G-code") + containerStackId: base.extruderStackId + settingKey: "machine_extruder_prestart_code" + settingStoreIndex: propertyStoreIndex + } + + Cura.GcodeTextArea // "Extruder Start G-code" + { + anchors.bottom: parent.bottom + anchors.left: parent.left + height: (parent.height / 2) - UM.Theme.getSize("default_margin").height + width: base.columnWidth - UM.Theme.getSize("default_margin").width + + labelText: catalog.i18nc("@title:label", "Extruder Start G-code") + containerStackId: base.extruderStackId + settingKey: "machine_extruder_start_code" + settingStoreIndex: propertyStoreIndex + } } Cura.GcodeTextArea // "Extruder End G-code" { anchors.top: parent.top anchors.bottom: parent.bottom - anchors.bottomMargin: UM.Theme.getSize("default_margin").height anchors.right: parent.right width: base.columnWidth - UM.Theme.getSize("default_margin").width diff --git a/plugins/MachineSettingsAction/MachineSettingsPrinterTab.qml b/plugins/MachineSettingsAction/MachineSettingsPrinterTab.qml index 740e248828..e57c28ddc8 100644 --- a/plugins/MachineSettingsAction/MachineSettingsPrinterTab.qml +++ b/plugins/MachineSettingsAction/MachineSettingsPrinterTab.qml @@ -344,6 +344,21 @@ Item labelWidth: base.labelWidth forceUpdateOnChangeFunction: forceUpdateFunction } + + /* + - Allows user to toggle if Start Gcode is the absolute first gcode. + */ + Cura.SimpleCheckBox // "Make sure Start Code is before all gcodes" + { + id: applyStartGcodeFirstCheckbox + containerStackId: machineStackId + settingKey: "machine_start_gcode_first" + settingStoreIndex: propertyStoreIndex + labelText: catalog.i18nc("@label", "Start GCode must be first") + labelFont: base.labelFont + labelWidth: base.labelWidth + forceUpdateOnChangeFunction: forceUpdateFunction + } /* The "Shared Heater" feature is temporarily disabled because its diff --git a/resources/definitions/fdmextruder.def.json b/resources/definitions/fdmextruder.def.json index f60cf63360..cb42948d6b 100644 --- a/resources/definitions/fdmextruder.def.json +++ b/resources/definitions/fdmextruder.def.json @@ -109,6 +109,17 @@ "type": "float", "unit": "mm" }, + "machine_extruder_prestart_code": + { + "default_value": "", + "description": "Prestart g-code to execute before switching to this extruder.", + "label": "Extruder Prestart G-Code", + "settable_globally": false, + "settable_per_extruder": true, + "settable_per_mesh": false, + "settable_per_meshgroup": false, + "type": "str" + }, "machine_extruder_start_code": { "default_value": "", @@ -120,6 +131,18 @@ "settable_per_meshgroup": false, "type": "str" }, + "machine_extruder_change_duration": + { + "default_value": 0, + "description": "When using a multi tool setup, this value is the tool change time in seconds. This value will be added to the estimate time based on the number of changes that occur.", + "label": "Extruder Change duration", + "minimum_value": "0", + "settable_globally": false, + "settable_per_extruder": true, + "settable_per_mesh": false, + "settable_per_meshgroup": false, + "type": "float" + }, "machine_extruder_start_code_duration": { "default_value": 0, @@ -278,4 +301,4 @@ "type": "category" } } -} \ No newline at end of file +} diff --git a/resources/definitions/fdmprinter.def.json b/resources/definitions/fdmprinter.def.json index 64196b9f8b..304a36a470 100644 --- a/resources/definitions/fdmprinter.def.json +++ b/resources/definitions/fdmprinter.def.json @@ -511,6 +511,16 @@ "settable_per_extruder": false, "settable_per_meshgroup": false }, + "machine_start_gcode_first": + { + "label": "Start GCode must be first", + "description": "This setting controls if the start-gcode is forced to always be the first g-code. Without this option other g-code, such as a T0 can be inserted before the start g-code.", + "type": "bool", + "default_value": false, + "settable_per_mesh": false, + "settable_per_extruder": false, + "settable_per_meshgroup": false + }, "extruder_prime_pos_z": { "label": "Extruder Prime Z Position", @@ -8961,4 +8971,4 @@ } } } -} \ No newline at end of file +}