Don't use material groups to find just the root container

Just look it up in the container registry. If you know the ID, this look-up is just a dictionary look-up as well.

Contributes to issue CURA-6600.
This commit is contained in:
Ghostkeeper 2019-09-13 14:40:43 +02:00
parent 882e60bf95
commit bb0c9c80dc
No known key found for this signature in database
GPG key ID: 86BEF881AE2CF276
2 changed files with 19 additions and 22 deletions

View file

@ -81,7 +81,7 @@ class UFPWriter(MeshWriter):
# Store the material.
application = CuraApplication.getInstance()
machine_manager = application.getMachineManager()
material_manager = application.getMaterialManager()
container_registry = application.getContainerRegistry()
global_stack = machine_manager.activeMachine
material_extension = "xml.fdm_material"
@ -107,12 +107,12 @@ class UFPWriter(MeshWriter):
continue
material_root_id = material.getMetaDataEntry("base_file")
material_group = material_manager.getMaterialGroup(material_root_id)
if material_group is None:
Logger.log("e", "Cannot find material container with root id [%s]", material_root_id)
material_root_query = container_registry.findContainers(id = material_root_id)
if not material_root_query:
Logger.log("e", "Cannot find material container with root id {root_id}".format(root_id = material_root_id))
return False
material_container = material_root_query[0]
material_container = material_group.root_material_node.container
try:
serialized_material = material_container.serialize()
except NotImplementedError: