mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-09 15:57:52 -06:00
Fix selecting a new material for a base file on container deletion
CURA-7023
This commit is contained in:
parent
2dc4681d91
commit
38935a1d02
1 changed files with 11 additions and 5 deletions
|
@ -167,15 +167,21 @@ class VariantNode(ContainerNode):
|
||||||
# Search for any submaterials from that base file that are still left.
|
# Search for any submaterials from that base file that are still left.
|
||||||
materials_same_base_file = ContainerRegistry.getInstance().findContainersMetadata(base_file = base_file)
|
materials_same_base_file = ContainerRegistry.getInstance().findContainersMetadata(base_file = base_file)
|
||||||
if materials_same_base_file:
|
if materials_same_base_file:
|
||||||
most_specific_submaterial = materials_same_base_file[0]
|
most_specific_submaterial = None
|
||||||
for submaterial in materials_same_base_file:
|
for submaterial in materials_same_base_file:
|
||||||
if submaterial["definition"] == self.machine.container_id:
|
if submaterial["definition"] == self.machine.container_id:
|
||||||
if most_specific_submaterial["definition"] == "fdmprinter":
|
if submaterial.get("variant_name", "empty") == self.variant_name:
|
||||||
most_specific_submaterial = submaterial
|
most_specific_submaterial = submaterial
|
||||||
if most_specific_submaterial.get("variant_name", "empty") == "empty" and submaterial.get("variant_name", "empty") == self.variant_name:
|
break # most specific match possible
|
||||||
|
if submaterial.get("variant_name", "empty") == "empty":
|
||||||
most_specific_submaterial = submaterial
|
most_specific_submaterial = submaterial
|
||||||
self.materials[base_file] = MaterialNode(most_specific_submaterial["id"], variant = self)
|
|
||||||
self.materialsChanged.emit(self.materials[base_file])
|
if most_specific_submaterial is None:
|
||||||
|
Logger.log("w", "Material %s removed, but no suitable replacement found", base_file)
|
||||||
|
else:
|
||||||
|
Logger.log("i", "Material %s (%s) overridden by %s", base_file, self.variant_name, most_specific_submaterial.get("id"))
|
||||||
|
self.materials[base_file] = MaterialNode(most_specific_submaterial["id"], variant = self)
|
||||||
|
self.materialsChanged.emit(self.materials[base_file])
|
||||||
|
|
||||||
if not self.materials: # The last available material just got deleted and there is nothing with the same base file to replace it.
|
if not self.materials: # The last available material just got deleted and there is nothing with the same base file to replace it.
|
||||||
self.materials["empty_material"] = MaterialNode("empty_material", variant = self)
|
self.materials["empty_material"] = MaterialNode("empty_material", variant = self)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue