Fixed crash when no transformation was provided in 3mf file

This commit is contained in:
Jaime van Kessel 2015-08-11 15:09:00 +02:00
parent cfe538c4b7
commit 102b2e7fa0

View file

@ -50,6 +50,7 @@ class ThreeMFReader(MeshReader):
node.setSelectable(True) node.setSelectable(True)
# Magical python comprehension; looks for the matching transformation # Magical python comprehension; looks for the matching transformation
transformation = next((x for x in root.model.build.item if x["objectid"] == object["id"]), None) transformation = next((x for x in root.model.build.item if x["objectid"] == object["id"]), None)
if transformation["transform"]:
splitted_transformation = transformation["transform"].split() splitted_transformation = transformation["transform"].split()
## Transformation is saved as: ## Transformation is saved as:
@ -95,9 +96,12 @@ class ThreeMFReader(MeshReader):
result.addChild(node) result.addChild(node)
# If there is more then one object, group them. # If there is more then one object, group them.
try:
if len(root.model.resources.object) > 1: if len(root.model.resources.object) > 1:
group_decorator = GroupDecorator() group_decorator = GroupDecorator()
result.addDecorator(group_decorator) result.addDecorator(group_decorator)
except:
pass
except Exception as e: except Exception as e:
print("EXCEPTION: " ,e) print("EXCEPTION: " ,e)
return result return result