Only match on printer-specific materials, not variant-specific too

If a submaterial doesn't exist for the current variant node but it does exist for a different variant node, then it would not be found in the variant-specific materials and then would be looked up in the printer-specific materials. It then depends on the order in which findInstanceContainersMetadata returns things for whether the actual printer-specific material is selected or a different variant-specific material is selected. No longer now, because the variant name is specified to be absent so it may not match on variant-specific profiles any more.
Maybe this even gives us a small performance gain when combining these dictionaries, since there are now like 80% fewer profiles in that query.

Contributes to issue CURA-6831.
This commit is contained in:
Ghostkeeper 2019-10-01 17:28:06 +02:00
parent 0b610ccd58
commit 649ca99fe0
No known key found for this signature in database
GPG key ID: 86BEF881AE2CF276

View file

@ -48,7 +48,7 @@ class VariantNode(ContainerNode):
# Find all the materials for this variant's name.
else: # Printer has its own material profiles. Look for material profiles with this printer's definition.
base_materials = container_registry.findInstanceContainersMetadata(type = "material", definition = "fdmprinter")
printer_specific_materials = container_registry.findInstanceContainersMetadata(type = "material", definition = self.machine.container_id)
printer_specific_materials = container_registry.findInstanceContainersMetadata(type = "material", definition = self.machine.container_id, variant_name = None)
variant_specific_materials = container_registry.findInstanceContainersMetadata(type = "material", definition = self.machine.container_id, variant_name = self.variant_name) # If empty_variant, this won't return anything.
materials_per_base_file = {material["base_file"]: material for material in base_materials}
materials_per_base_file.update({material["base_file"]: material for material in printer_specific_materials}) # Printer-specific profiles override global ones.