Browse Source

Prevent UFP writer from crashing if the base file of a material can not be found

Another issue found in the crash reports
Jaime van Kessel 6 years ago
parent
commit
1a037bdb82
1 changed files with 6 additions and 2 deletions
  1. 6 2
      plugins/UFPWriter/UFPWriter.py

+ 6 - 2
plugins/UFPWriter/UFPWriter.py

@@ -95,10 +95,14 @@ class UFPWriter(MeshWriter):
         added_materials = []
         for extruder_stack in global_stack.extruders.values():
             material = extruder_stack.material
-            material_file_name = material.getMetaData()["base_file"] + ".xml.fdm_material"
+            try:
+                material_file_name = material.getMetaData()["base_file"] + ".xml.fdm_material"
+            except KeyError:
+                Logger.log("w", "Unable to get base_file for the material %s", material.getId())
+                continue
             material_file_name = "/Materials/" + material_file_name
 
-            #Same material cannot be added
+            # The same material should not be added again.
             if material_file_name in added_materials:
                 continue