diff --git a/cura/Machines/VariantNode.py b/cura/Machines/VariantNode.py index fa0c61bd3d..a9a6608d27 100644 --- a/cura/Machines/VariantNode.py +++ b/cura/Machines/VariantNode.py @@ -1,6 +1,5 @@ # Copyright (c) 2019 Ultimaker B.V. # Cura is released under the terms of the LGPLv3 or higher. - from typing import Optional, TYPE_CHECKING from UM.Logger import Logger @@ -111,18 +110,18 @@ class VariantNode(ContainerNode): if base_file not in self.materials: # Completely new base file. Always better than not having a file as long as it matches our set-up. if material_definition != "fdmprinter" and material_definition != self.machine.container_id: return - material_variant = container.getMetaDataEntry("variant_name", "empty") - if material_variant != "empty" and material_variant != self.variant_name: + material_variant = container.getMetaDataEntry("variant_name") + if material_variant is not None and material_variant != self.variant_name: return else: # We already have this base profile. Replace the base profile if the new one is more specific. new_definition = container.getMetaDataEntry("definition") if new_definition == "fdmprinter": return # Just as unspecific or worse. - if new_definition != self.machine.container_id: + material_variant = container.getMetaDataEntry("variant_name") + if new_definition != self.machine.container_id or material_variant != self.variant_name: return # Doesn't match this set-up. original_metadata = ContainerRegistry.getInstance().findContainersMetadata(id = self.materials[base_file].container_id)[0] - original_variant = original_metadata.get("variant_name", "empty") - if original_variant != "empty" or container.getMetaDataEntry("variant_name", "empty") == "empty": + if "variant_name" in original_metadata or material_variant is not None: return # Original was already specific or just as unspecific as the new one. if "empty_material" in self.materials: diff --git a/resources/qml/Preferences/Materials/MaterialsList.qml b/resources/qml/Preferences/Materials/MaterialsList.qml index 96f6730029..8b82a87820 100644 --- a/resources/qml/Preferences/Materials/MaterialsList.qml +++ b/resources/qml/Preferences/Materials/MaterialsList.qml @@ -114,7 +114,7 @@ Item if (base.toActivateNewMaterial) { var position = Cura.ExtruderManager.activeExtruderIndex - Cura.MachineManager.setMaterial(position, base.currentItem.container_node) + Cura.MachineManager.setMaterialById(position, base.newRootMaterialIdToSwitchTo) } base.newRootMaterialIdToSwitchTo = "" base.toActivateNewMaterial = false