You can now select group and system data in selectors

This commit is contained in:
Dion Moult
2024-07-10 17:30:32 +10:00
parent 670bf9d4a6
commit 4e78de6ce9
2 changed files with 9 additions and 1 deletions
@@ -183,8 +183,11 @@ Valid keys are:
"``space``", "Gets the first IfcSpace spatial element that an element is contained in." "``space``", "Gets the first IfcSpace spatial element that an element is contained in."
"``storey``", "Gets the first IfcBuildingStorey spatial element that an element is contained in." "``storey``", "Gets the first IfcBuildingStorey spatial element that an element is contained in."
"``building``", "Gets the first IfcBuilding spatial element that an element is contained in." "``building``", "Gets the first IfcBuilding spatial element that an element is contained in."
"``site``", "Gets the first IccSite spatial element that an element is contained in." "``site``", "Gets the first IfcSite spatial element that an element is contained in."
"``parent``", "Gets the parent element in the spatial hierarchy." "``parent``", "Gets the parent element in the spatial hierarchy."
"``classification``", "Gets the element's classification reference(s)"
"``group``", "Gets the element's group(s)"
"``system``", "Gets the element's system(s). This is a subset of group(s)."
"``material`` or ``mat``", "Gets the assigned material, which may be a material set." "``material`` or ``mat``", "Gets the assigned material, which may be a material set."
"``item`` or ``i``", "If the previous key returns a material set, gets the relevant material set items" "``item`` or ``i``", "If the previous key returns a material set, gets the relevant material set items"
"``materials`` or ``mats``", "Gets a list of IfcMaterials assigned directly or indirectly (such as via a material set) to the element" "``materials`` or ``mats``", "Gets a list of IfcMaterials assigned directly or indirectly (such as via a material set) to the element"
@@ -31,6 +31,7 @@ import ifcopenshell.util.geolocation
import ifcopenshell.util.classification import ifcopenshell.util.classification
import ifcopenshell.util.schema import ifcopenshell.util.schema
import ifcopenshell.util.shape import ifcopenshell.util.shape
import ifcopenshell.util.system
from decimal import Decimal from decimal import Decimal
from typing import Optional, Any, Union, Iterable from typing import Optional, Any, Union, Iterable
@@ -331,6 +332,10 @@ def _get_element_value(element: ifcopenshell.entity_instance, keys: list[str]) -
value = value.id() value = value.id()
elif key == "classification": elif key == "classification":
value = ifcopenshell.util.classification.get_references(value) value = ifcopenshell.util.classification.get_references(value)
elif key == "group":
value = ifcopenshell.util.element.get_groups(value)
elif key == "system":
value = ifcopenshell.util.system.get_element_systems(value)
elif key in ("x", "y", "z", "easting", "northing", "elevation") and hasattr(value, "ObjectPlacement"): elif key in ("x", "y", "z", "easting", "northing", "elevation") and hasattr(value, "ObjectPlacement"):
if getattr(value, "ObjectPlacement", None): if getattr(value, "ObjectPlacement", None):
matrix = ifcopenshell.util.placement.get_local_placement(value.ObjectPlacement) matrix = ifcopenshell.util.placement.get_local_placement(value.ObjectPlacement)