diff --git a/cura/Settings/CuraContainerRegistry.py b/cura/Settings/CuraContainerRegistry.py index a67b502b4a..ed63e10909 100644 --- a/cura/Settings/CuraContainerRegistry.py +++ b/cura/Settings/CuraContainerRegistry.py @@ -340,10 +340,8 @@ class CuraContainerRegistry(ContainerRegistry): # \return the ID of the active material or the empty string def _activeMaterialId(self): global_container_stack = Application.getInstance().getGlobalContainerStack() - if global_container_stack: - material = global_container_stack.findContainer({"type": "material"}) - if material: - return material.getId() + if global_container_stack and global_container_stack.material: + return global_container_stack.material.getId() return "" ## Returns true if the current machien requires its own quality profiles diff --git a/cura/Settings/MachineManager.py b/cura/Settings/MachineManager.py index 61fec50992..6499e527f5 100755 --- a/cura/Settings/MachineManager.py +++ b/cura/Settings/MachineManager.py @@ -157,7 +157,7 @@ class MachineManager(QObject): if str(index) == extruder.getMetaDataEntry("position"): matching_extruder = extruder break - if matching_extruder and matching_extruder.findContainer({"type": "variant"}).getName() != hotend_id: + if matching_extruder and matching_extruder.variant.getName() != hotend_id: # Save the material that needs to be changed. Multiple changes will be handled by the callback. self._auto_hotends_changed[str(index)] = containers[0].getId() self._printer_output_devices[0].materialHotendChangedMessage(self._materialHotendChangedCallback) @@ -181,11 +181,10 @@ class MachineManager(QObject): matching_extruder = extruder break - if matching_extruder and matching_extruder.findContainer({"type": "material"}).getMetaDataEntry("GUID") != material_id: + if matching_extruder and matching_extruder.material.getMetaDataEntry("GUID") != material_id: # Save the material that needs to be changed. Multiple changes will be handled by the callback. - variant_container = matching_extruder.findContainer({"type": "variant"}) - if self._global_container_stack.getBottom().getMetaDataEntry("has_variants") and variant_container: - variant_id = self.getQualityVariantId(self._global_container_stack.getBottom(), variant_container) + if self._global_container_stack.getBottom().getMetaDataEntry("has_variants") and matching_extruder.variant: + variant_id = self.getQualityVariantId(self._global_container_stack.getBottom(), matching_extruder.variant) for container in containers: if container.getMetaDataEntry("variant") == variant_id: self._auto_materials_changed[str(index)] = container.getId() @@ -507,9 +506,8 @@ class MachineManager(QObject): result = [] if ExtruderManager.getInstance().getActiveGlobalAndExtruderStacks() is not None: for stack in ExtruderManager.getInstance().getActiveGlobalAndExtruderStacks(): - variant_container = stack.findContainer({"type": "variant"}) - if variant_container and variant_container != self._empty_variant_container: - result.append(variant_container.getId()) + if stack.variant and stack.variant != self._empty_variant_container: + result.append(stack.variant.getId()) return result diff --git a/cura/Settings/ProfilesModel.py b/cura/Settings/ProfilesModel.py index 9056273216..18acb5e9e8 100644 --- a/cura/Settings/ProfilesModel.py +++ b/cura/Settings/ProfilesModel.py @@ -107,9 +107,9 @@ class ProfilesModel(InstanceContainersModel): continue #Quality has no value for layer height either. Get the layer height from somewhere lower in the stack. - skip_until_container = global_container_stack.findContainer({"type": "material"}) + skip_until_container = global_container_stack.material if not skip_until_container: #No material in stack. - skip_until_container = global_container_stack.findContainer({"type": "variant"}) + skip_until_container = global_container_stack.variant if not skip_until_container: #No variant in stack. skip_until_container = global_container_stack.getBottom() item["layer_height"] = str(global_container_stack.getRawProperty("layer_height", "value", skip_until_container = skip_until_container.getId())) + unit #Fall through to the currently loaded material. diff --git a/plugins/UltimakerMachineActions/UMOUpgradeSelection.py b/plugins/UltimakerMachineActions/UMOUpgradeSelection.py index 70a9d3fa0e..476089e533 100644 --- a/plugins/UltimakerMachineActions/UMOUpgradeSelection.py +++ b/plugins/UltimakerMachineActions/UMOUpgradeSelection.py @@ -36,7 +36,7 @@ class UMOUpgradeSelection(MachineAction): global_container_stack = Application.getInstance().getGlobalContainerStack() if global_container_stack: # Make sure there is a definition_changes container to store the machine settings - definition_changes_container = global_container_stack.findContainer({"type": "definition_changes"}) + definition_changes_container = global_container_stack.definition_changes if not definition_changes_container: definition_changes_container = self._createDefinitionChangesContainer(global_container_stack)