Remove has_machine_materials metadata

It's not behaving as expected here. For instance, Ultimaker 3 wasn't specifying has_machine_materials and thus only the base materials would get loaded, but clearly the Ultimaker 3 has materials specialised for it.
Whether or not a printer has materials specialised for it is now determined by whether the specialisations exist in the material files. So we don't need the metadata entry any more. It seemed to have not been in use anyway, except by one printer which specified that has_machine_materials is true. I've now made it behave as if it's always true.

Contributes to issue CURA-6831.
This commit is contained in:
Ghostkeeper 2019-10-01 15:53:34 +02:00
parent 179fa325fc
commit b245be6970
No known key found for this signature in database
GPG key ID: 86BEF881AE2CF276
4 changed files with 2 additions and 10 deletions

View file

@ -36,7 +36,6 @@ class MachineNode(ContainerNode):
# Otherwise you need to keep it up-to-date during runtime.
self.has_materials = parseBool(my_metadata.get("has_materials", "true"))
self.has_variants = parseBool(my_metadata.get("has_variants", "false"))
self.has_machine_materials = parseBool(my_metadata.get("has_machine_materials", "false"))
self.has_machine_quality = parseBool(my_metadata.get("has_machine_quality", "false"))
self.quality_definition = my_metadata.get("quality_definition", container_id) if self.has_machine_quality else "fdmprinter"
self.exclude_materials = my_metadata.get("exclude_materials", [])

View file

@ -46,13 +46,11 @@ class VariantNode(ContainerNode):
return # There should not be any materials loaded for this printer.
# Find all the materials for this variant's name.
if not self.machine.has_machine_materials: # Printer has no specific materials. Look for all fdmprinter materials.
materials = container_registry.findInstanceContainersMetadata(type = "material", definition = "fdmprinter") # These are ONLY the base materials.
else: # Printer has its own material profiles. Look for material profiles with this printer's definition.
all_materials = container_registry.findInstanceContainersMetadata(type = "material", definition = "fdmprinter")
base_materials = container_registry.findInstanceContainersMetadata(type = "material", definition = "fdmprinter")
printer_specific_materials = container_registry.findInstanceContainersMetadata(type = "material", definition = self.machine.container_id)
variant_specific_materials = container_registry.findInstanceContainersMetadata(type = "material", definition = self.machine.container_id, variant = self.variant_name) # If empty_variant, this won't return anything.
materials_per_base_file = {material["base_file"]: material for material in all_materials}
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.
materials_per_base_file.update({material["base_file"]: material for material in variant_specific_materials}) # Variant-specific profiles override all of those.
materials = list(materials_per_base_file.values())
@ -100,9 +98,6 @@ class VariantNode(ContainerNode):
if not self.machine.has_materials:
return # We won't add any materials.
material_definition = container.getMetaDataEntry("definition")
if not self.machine.has_machine_materials:
if material_definition != "fdmprinter":
return
base_file = container.getMetaDataEntry("base_file")
if base_file in self.machine.exclude_materials:

View file

@ -9,7 +9,6 @@
"file_formats": "text/x-gcode",
"has_materials": true,
"has_machine_materials": true,
"preferred_material": "generic_pla",
"exclude_materials": [
"chromatik_pla",

View file

@ -7,7 +7,6 @@ from cura.Machines.MachineNode import MachineNode
metadata_dict = {
"has_materials": "false",
"has_variants": "true",
"has_machine_materials": "true",
"has_machine_quality": "true",
"quality_definition": "test_quality_definition",
"exclude_materials": ["excluded_material_1", "excluded_material_2"],