mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-20 06:58:56 +00:00
IfcStore.get_element - more explicit checks for missing elements
This commit is contained in:
@@ -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
|
||||||
|
|||||||
Reference in New Issue
Block a user