IfcStore.get_element - more explicit checks for missing elements

This commit is contained in:
Andrej730
2024-06-14 12:23:33 +05:00
parent b6b681c244
commit d0f612afc2
+6 -7
View File
@@ -179,14 +179,13 @@ class IfcStore:
@staticmethod @staticmethod
def get_element(id_or_guid: Union[int, str]) -> IFC_CONNECTED_TYPE: def get_element(id_or_guid: Union[int, str]) -> IFC_CONNECTED_TYPE:
if isinstance(id_or_guid, int): if isinstance(id_or_guid, int):
map_object = IfcStore.id_map obj = IfcStore.id_map.get(id_or_guid)
else: else:
map_object = IfcStore.guid_map obj = IfcStore.guid_map.get(id_or_guid)
try: if obj is None:
obj = map_object[id_or_guid] return None
obj.name # In case the object has been deleted, this triggers an exception if not tool.Blender.is_valid_data_block(obj):
except: return None
return
return obj return obj
@staticmethod @staticmethod