When unable to find quality for material, we also use inherited files (if any) to resolve it

CURA-2108
This commit is contained in:
Jaime van Kessel 2016-08-30 16:01:21 +02:00
parent 0a811b2164
commit dcbf7b5a35

View file

@ -19,6 +19,7 @@ from UM.i18n import i18nCatalog
catalog = i18nCatalog("cura")
import time
import os
class MachineManager(QObject):
def __init__(self, parent = None):
@ -833,7 +834,22 @@ class MachineManager(QObject):
return containers[0]
if "material" in search_criteria:
# If a quality for this specific material cannot be found, try finding qualities for a generic version of the material
# First check if we can solve our material not found problem by checking if we can find quality containers
# that are assigned to the parents of this material profile.
try:
inherited_files = material_container.getInheritedFiles()
if inherited_files:
for inherited_file in inherited_files:
# Extract the ID from the path we used to load the file.
search_criteria["material"] = os.path.basename(inherited_file).split(".")[0]
containers = container_registry.findInstanceContainers(**search_criteria)
if containers:
return containers[0]
except AttributeError: # Material_container does not support inheritance.
pass
# We still weren't able to find a quality for this specific material.
# Try to find qualities for a generic version of the material.
material_search_criteria = { "type": "material", "material": material_container.getMetaDataEntry("material"), "color_name": "Generic" }
if definition.getMetaDataEntry("has_machine_quality"):
if material_container: