mirror of
https://git.mirrors.martin98.com/https://github.com/Ultimaker/Cura
synced 2025-08-13 01:49:03 +08:00
Fix selecting a new material for a base file on container deletion
CURA-7023
This commit is contained in:
parent
b77de636d4
commit
cef0ae349d
@ -168,15 +168,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…
x
Reference in New Issue
Block a user