From d6f116b156c63ab33eb46644d7fdae3e8f429ebe Mon Sep 17 00:00:00 2001 From: Ghostkeeper Date: Thu, 14 Feb 2019 14:03:38 +0100 Subject: [PATCH 1/2] Don't crash on editing metadata entries of non-registered materials Sometimes we need to create a temporary material profile just to save it to file. Contributes to issue CURA-5787. --- plugins/XmlMaterialProfile/XmlMaterialProfile.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/plugins/XmlMaterialProfile/XmlMaterialProfile.py b/plugins/XmlMaterialProfile/XmlMaterialProfile.py index 011941eec7..febec2bd34 100644 --- a/plugins/XmlMaterialProfile/XmlMaterialProfile.py +++ b/plugins/XmlMaterialProfile/XmlMaterialProfile.py @@ -71,7 +71,9 @@ class XmlMaterialProfile(InstanceContainer): material_manager = CuraApplication.getInstance().getMaterialManager() root_material_id = self.getMetaDataEntry("base_file") #if basefile is self.getId, this is a basefile. material_group = material_manager.getMaterialGroup(root_material_id) - + if not material_group: #If the profile is not registered in the registry but loose/temporary, it will not have a base file tree. + super().setMetaDataEntry(key, value) + return # Update the root material container root_material_container = material_group.root_material_node.getContainer() if root_material_container is not None: From cc94441b5439d1b6d378a5bbe07cfdc1a4d5db5e Mon Sep 17 00:00:00 2001 From: Ghostkeeper Date: Thu, 14 Feb 2019 17:45:25 +0100 Subject: [PATCH 2/2] Fix serialising materials with Ultimaker S5 in it Contributes to issue CURA-5787. --- plugins/XmlMaterialProfile/XmlMaterialProfile.py | 2 ++ plugins/XmlMaterialProfile/product_to_id.json | 1 + 2 files changed, 3 insertions(+) diff --git a/plugins/XmlMaterialProfile/XmlMaterialProfile.py b/plugins/XmlMaterialProfile/XmlMaterialProfile.py index febec2bd34..4763205fec 100644 --- a/plugins/XmlMaterialProfile/XmlMaterialProfile.py +++ b/plugins/XmlMaterialProfile/XmlMaterialProfile.py @@ -1167,6 +1167,8 @@ class XmlMaterialProfile(InstanceContainer): with open(product_to_id_file, encoding = "utf-8") as f: product_to_id_map = json.load(f) product_to_id_map = {key: [value] for key, value in product_to_id_map.items()} + #This also loads "Ultimaker S5" -> "ultimaker_s5" even though that is not strictly necessary with the default to change spaces into underscores. + #However it is not always loaded with that default; this mapping is also used in serialize() without that default. return product_to_id_map ## Parse the value of the "material compatible" property. diff --git a/plugins/XmlMaterialProfile/product_to_id.json b/plugins/XmlMaterialProfile/product_to_id.json index 3e7ce9311f..6b78d3fe64 100644 --- a/plugins/XmlMaterialProfile/product_to_id.json +++ b/plugins/XmlMaterialProfile/product_to_id.json @@ -6,6 +6,7 @@ "Ultimaker 2+": "ultimaker2_plus", "Ultimaker 3": "ultimaker3", "Ultimaker 3 Extended": "ultimaker3_extended", + "Ultimaker S5": "ultimaker_s5", "Ultimaker Original": "ultimaker_original", "Ultimaker Original+": "ultimaker_original_plus", "Ultimaker Original Dual Extrusion": "ultimaker_original_dual",