Fix error when trying to select type if type is not set

This commit is contained in:
Gorgious
2021-08-19 22:06:56 +02:00
parent 29cda05025
commit 9b9326721d
@@ -136,13 +136,13 @@ class SelectType(bpy.types.Operator):
def execute(self, context):
self.file = IfcStore.get_file()
related_object = bpy.data.objects.get(self.related_object) if self.related_object else context.active_object
related_object = bpy.data.objects.get(self.related_object, context.active_object)
oprops = related_object.BIMObjectProperties
obj = IfcStore.get_element(
ifcopenshell.util.element.get_type(self.file.by_id(oprops.ifc_definition_id)).GlobalId
)
context.view_layer.objects.active = obj
obj.select_set(True)
element_type = ifcopenshell.util.element.get_type(self.file.by_id(oprops.ifc_definition_id))
if element_type is not None:
obj = IfcStore.get_element(element_type.GlobalId)
context.view_layer.objects.active = obj
obj.select_set(True)
return {"FINISHED"}