Don't add materials forbidden by the printer definition

Contributes to issue CURA-6600.
This commit is contained in:
Ghostkeeper 2019-08-06 15:21:52 +02:00
parent 3ef0b4292d
commit 24346fc8e3
No known key found for this signature in database
GPG key ID: 86BEF881AE2CF276
2 changed files with 8 additions and 1 deletions

View file

@ -20,7 +20,9 @@ class MachineNode(ContainerNode):
super().__init__(container_id, None)
self.variants = {} # type: Dict[str, VariantNode] # mapping variant names to their nodes.
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)
self._loadAll()

View file

@ -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 = materials_per_base_file.values()
for excluded_material in self.parent.exclude_materials:
del materials[excluded_material]
for material in materials:
base_file = material["base_file"]
if base_file not in self.materials:
@ -60,6 +63,8 @@ class VariantNode(ContainerNode):
if material_definition != "fdmprinter":
return
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 material_definition != "fdmprinter" and material_definition != self.parent.container_id:
return