mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-23 14:44:13 -06:00
Don't add materials forbidden by the printer definition
Contributes to issue CURA-6600.
This commit is contained in:
parent
3ef0b4292d
commit
24346fc8e3
2 changed files with 8 additions and 1 deletions
|
@ -20,7 +20,9 @@ class MachineNode(ContainerNode):
|
||||||
super().__init__(container_id, None)
|
super().__init__(container_id, None)
|
||||||
self.variants = {} # type: Dict[str, VariantNode] # mapping variant names to their nodes.
|
self.variants = {} # type: Dict[str, VariantNode] # mapping variant names to their nodes.
|
||||||
container_registry = ContainerRegistry.getInstance()
|
container_registry = ContainerRegistry.getInstance()
|
||||||
self.has_machine_materials = parseBool(container_registry.findContainersMetadata(id = container_id)[0].get("has_machine_materials", "true"))
|
my_metadata = container_registry.findContainersMetadata(id = container_id)[0]
|
||||||
|
self.has_machine_materials = parseBool(my_metadata.get("has_machine_materials", "true"))
|
||||||
|
self.exclude_materials = my_metadata.get("exclude_materials", [])
|
||||||
container_registry.containerAdded.connect(self._variantAdded)
|
container_registry.containerAdded.connect(self._variantAdded)
|
||||||
self._loadAll()
|
self._loadAll()
|
||||||
|
|
||||||
|
|
|
@ -45,6 +45,9 @@ class VariantNode(ContainerNode):
|
||||||
materials_per_base_file.update({material["base_file"]: material for material in variant_specific_materials}) # Variant-specific profiles override all of those.
|
materials_per_base_file.update({material["base_file"]: material for material in variant_specific_materials}) # Variant-specific profiles override all of those.
|
||||||
materials = materials_per_base_file.values()
|
materials = materials_per_base_file.values()
|
||||||
|
|
||||||
|
for excluded_material in self.parent.exclude_materials:
|
||||||
|
del materials[excluded_material]
|
||||||
|
|
||||||
for material in materials:
|
for material in materials:
|
||||||
base_file = material["base_file"]
|
base_file = material["base_file"]
|
||||||
if base_file not in self.materials:
|
if base_file not in self.materials:
|
||||||
|
@ -60,6 +63,8 @@ class VariantNode(ContainerNode):
|
||||||
if material_definition != "fdmprinter":
|
if material_definition != "fdmprinter":
|
||||||
return
|
return
|
||||||
base_file = container.getMetaDataEntry("base_file")
|
base_file = container.getMetaDataEntry("base_file")
|
||||||
|
if base_file in self.parent.exclude_materials:
|
||||||
|
return # Material is forbidden for this printer.
|
||||||
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 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.parent.container_id:
|
if material_definition != "fdmprinter" and material_definition != self.parent.container_id:
|
||||||
return
|
return
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue