You can now get specific container types via util.element or util.selector. E.g. if you wanted to know what building an object is in or what storey an object is on.

This commit is contained in:
Dion Moult
2023-08-21 23:06:49 +10:00
parent b998e1c927
commit 2dd6b164a9
2 changed files with 32 additions and 3 deletions
@@ -151,6 +151,14 @@ def set_element_value(ifc_file, element, query, value):
element = element.MaterialConstituents
elif key == "container":
element = ifcopenshell.util.element.get_container(element)
elif key == "space":
element = ifcopenshell.util.element.get_container(element, ifc_class="IfcSpace")
elif key == "storey":
element = ifcopenshell.util.element.get_container(element, ifc_class="IfcBuildingStorey")
elif key == "building":
element = ifcopenshell.util.element.get_container(element, ifc_class="IfcBuilding")
elif key == "site":
element = ifcopenshell.util.element.get_container(element, ifc_class="IfcSite")
elif key == "class":
if element.is_a() != value:
return ifcopenshell.util.schema.reassign_class(ifc_file, element, value)
@@ -637,6 +645,14 @@ class Selector:
value = value.MaterialConstituents
elif key == "container":
value = ifcopenshell.util.element.get_container(value)
elif key == "space":
element = ifcopenshell.util.element.get_container(element, ifc_class="IfcSpace")
elif key == "storey":
element = ifcopenshell.util.element.get_container(element, ifc_class="IfcBuildingStorey")
elif key == "building":
element = ifcopenshell.util.element.get_container(element, ifc_class="IfcBuilding")
elif key == "site":
element = ifcopenshell.util.element.get_container(element, ifc_class="IfcSite")
elif key == "class":
value = value.is_a()
elif key == "id":