From e8a723739128ade9d8f0c370e1fb5ccb5203da43 Mon Sep 17 00:00:00 2001 From: fieldOfView Date: Thu, 30 Nov 2017 11:46:06 +0100 Subject: [PATCH] Fix updating material container for extruder when changing gcode flavor Since single extrusion printers have a single extruder stack now, material container needs to be set on the extruder stack instead of the global stack --- .../MachineSettingsAction.py | 21 +++++++++++-------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/plugins/MachineSettingsAction/MachineSettingsAction.py b/plugins/MachineSettingsAction/MachineSettingsAction.py index 2de5b6e9b8..7b407519e5 100755 --- a/plugins/MachineSettingsAction/MachineSettingsAction.py +++ b/plugins/MachineSettingsAction/MachineSettingsAction.py @@ -188,29 +188,32 @@ class MachineSettingsAction(MachineAction): # In other words: only continue for the UM2 (extended), but not for the UM2+ return + stacks = ExtruderManager.getInstance().getExtruderStacks() has_materials = self._global_container_stack.getProperty("machine_gcode_flavor", "value") != "UltiGCode" - material_container = self._global_container_stack.material - if has_materials: if "has_materials" in self._global_container_stack.getMetaData(): self._global_container_stack.setMetaDataEntry("has_materials", True) else: self._global_container_stack.addMetaDataEntry("has_materials", True) - # Set the material container to a sane default - if material_container == self._empty_container: - search_criteria = { "type": "material", "definition": "fdmprinter", "id": self._global_container_stack.getMetaDataEntry("preferred_material")} - materials = self._container_registry.findInstanceContainers(**search_criteria) - if materials: - self._global_container_stack.material = materials[0] + # Set the material container for each extruder to a sane default + for stack in stacks: + material_container = stack.material + if material_container == self._empty_container: + machine_approximate_diameter = str(round(self._global_container_stack.getProperty("material_diameter", "value"))) + search_criteria = { "type": "material", "definition": "fdmprinter", "id": self._global_container_stack.getMetaDataEntry("preferred_material"), "approximate_diameter": machine_approximate_diameter} + materials = self._container_registry.findInstanceContainers(**search_criteria) + if materials: + stack.material = materials[0] else: # The metadata entry is stored in an ini, and ini files are parsed as strings only. # Because any non-empty string evaluates to a boolean True, we have to remove the entry to make it False. if "has_materials" in self._global_container_stack.getMetaData(): self._global_container_stack.removeMetaDataEntry("has_materials") - self._global_container_stack.material = ContainerRegistry.getInstance().getEmptyInstanceContainer() + for stack in stacks: + stack.material = ContainerRegistry.getInstance().getEmptyInstanceContainer() Application.getInstance().globalContainerStackChanged.emit()