Merge branch 'CURA-5887_fix_material_shown_in_print_job' of github.com:Ultimaker/Cura

This commit is contained in:
Jaime van Kessel 2018-11-07 12:39:41 +01:00
commit 36a9642c90

View File

@ -590,13 +590,27 @@ class ClusterUM3OutputDevice(NetworkedPrinterOutputDevice):
origin_name=change["origin_name"])) origin_name=change["origin_name"]))
return result return result
def _createMaterialOutputModel(self, material_data) -> MaterialOutputModel: def _createMaterialOutputModel(self, material_data: Dict[str, Any]) -> "MaterialOutputModel":
containers = ContainerRegistry.getInstance().findInstanceContainers(type="material", GUID=material_data["guid"]) material_manager = CuraApplication.getInstance().getMaterialManager()
if containers: material_group_list = material_manager.getMaterialGroupListByGUID(material_data["guid"])
color = containers[0].getMetaDataEntry("color_code")
brand = containers[0].getMetaDataEntry("brand") # Sort the material groups by "is_read_only = True" first, and then the name alphabetically.
material_type = containers[0].getMetaDataEntry("material") read_only_material_group_list = list(filter(lambda x: x.is_read_only, material_group_list))
name = containers[0].getName() non_read_only_material_group_list = list(filter(lambda x: not x.is_read_only, material_group_list))
material_group = None
if read_only_material_group_list:
read_only_material_group_list = sorted(read_only_material_group_list, key = lambda x: x.name)
material_group = read_only_material_group_list[0]
elif non_read_only_material_group_list:
non_read_only_material_group_list = sorted(non_read_only_material_group_list, key = lambda x: x.name)
material_group = non_read_only_material_group_list[0]
if material_group:
container = material_group.root_material_node.getContainer()
color = container.getMetaDataEntry("color_code")
brand = container.getMetaDataEntry("brand")
material_type = container.getMetaDataEntry("material")
name = container.getName()
else: else:
Logger.log("w", Logger.log("w",
"Unable to find material with guid {guid}. Using data as provided by cluster".format( "Unable to find material with guid {guid}. Using data as provided by cluster".format(