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
def get_element(id_or_guid: Union[int, str]) -> IFC_CONNECTED_TYPE:
if isinstance(id_or_guid, int):
map_object = IfcStore.id_map
obj = IfcStore.id_map.get(id_or_guid)
else:
map_object = IfcStore.guid_map
try:
obj = map_object[id_or_guid]
obj.name # In case the object has been deleted, this triggers an exception
except:
return
obj = IfcStore.guid_map.get(id_or_guid)
if obj is None:
return None
if not tool.Blender.is_valid_data_block(obj):
return None
return obj
@staticmethod