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

Another issue found in the crash reports
This commit is contained in:
Jaime van Kessel 2019-01-31 14:48:40 +01:00
parent d5e34cc9c9
commit 1a037bdb82

View file

@ -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