diff --git a/cura/CuraApplication.py b/cura/CuraApplication.py index 05070e4432..2a2283d3a5 100755 --- a/cura/CuraApplication.py +++ b/cura/CuraApplication.py @@ -181,6 +181,7 @@ class CuraApplication(QtApplication): SettingFunction.registerOperator("extruderValues", ExtruderManager.getExtruderValues) SettingFunction.registerOperator("extruderValue", ExtruderManager.getExtruderValue) SettingFunction.registerOperator("resolveOrValue", ExtruderManager.getResolveOrValue) + SettingFunction.registerOperator("defaultExtruderPosition", ExtruderManager.getDefaultExtruderPosition) ## Add the 4 types of profiles to storage. Resources.addStorageType(self.ResourceTypes.QualityInstanceContainer, "quality") diff --git a/cura/Settings/ExtruderManager.py b/cura/Settings/ExtruderManager.py index 51e7e81fef..7e7fe45cb2 100755 --- a/cura/Settings/ExtruderManager.py +++ b/cura/Settings/ExtruderManager.py @@ -557,6 +557,11 @@ class ExtruderManager(QObject): return result + ## Return the default extruder position from the machine manager + @staticmethod + def getDefaultExtruderPosition() -> str: + return Application.getInstance().getMachineManager().defaultExtruderPosition + ## Get all extruder values for a certain setting. # # This is exposed to qml for display purposes diff --git a/plugins/CuraEngineBackend/StartSliceJob.py b/plugins/CuraEngineBackend/StartSliceJob.py index 0297a34385..467351dd4b 100644 --- a/plugins/CuraEngineBackend/StartSliceJob.py +++ b/plugins/CuraEngineBackend/StartSliceJob.py @@ -287,14 +287,9 @@ class StartSliceJob(Job): # \return A dictionary of replacement tokens to the values they should be # replaced with. def _buildReplacementTokens(self, stack) -> dict: - default_extruder_position = int(Application.getInstance().getMachineManager().defaultExtruderPosition) result = {} for key in stack.getAllKeys(): - setting_type = stack.definition.getProperty(key, "type") value = stack.getProperty(key, "value") - if setting_type == "extruder" and value == -1: - # replace with the default value - value = default_extruder_position result[key] = value Job.yieldThread() diff --git a/resources/definitions/fdmprinter.def.json b/resources/definitions/fdmprinter.def.json index 25fe841ee4..1c43225472 100644 --- a/resources/definitions/fdmprinter.def.json +++ b/resources/definitions/fdmprinter.def.json @@ -3621,7 +3621,7 @@ "description": "The extruder train to use for printing the support. This is used in multi-extrusion.", "type": "extruder", "default_value": "0", - "value": "-1", + "value": "defaultExtruderPosition()", "enabled": "(support_enable or support_tree_enable) and extruders_enabled_count > 1", "settable_per_mesh": false, "settable_per_extruder": false, @@ -4362,7 +4362,7 @@ "description": "The extruder train to use for printing the skirt/brim/raft. This is used in multi-extrusion.", "type": "extruder", "default_value": "0", - "value": "-1", + "value": "defaultExtruderPosition()", "enabled": "extruders_enabled_count > 1 and resolveOrValue('adhesion_type') != 'none'", "settable_per_mesh": false, "settable_per_extruder": false diff --git a/resources/qml/Settings/SettingExtruder.qml b/resources/qml/Settings/SettingExtruder.qml index 38b1c2cab0..2239628e3f 100644 --- a/resources/qml/Settings/SettingExtruder.qml +++ b/resources/qml/Settings/SettingExtruder.qml @@ -93,14 +93,7 @@ SettingItem { target: control property: "currentIndex" - value: - { - if(propertyProvider.properties.value == -1) - { - return control.getIndexByPosition(Cura.MachineManager.defaultExtruderPosition); - } - return propertyProvider.properties.value - } + value: control.getIndexByPosition(propertyProvider.properties.value) // Sometimes when the value is already changed, the model is still being built. // The when clause ensures that the current index is not updated when this happens. when: control.model.items.length > 0