From 4e78de6ce92961d3228b439b269f7ca63ffb6437 Mon Sep 17 00:00:00 2001 From: Dion Moult Date: Wed, 10 Jul 2024 17:30:32 +1000 Subject: [PATCH] You can now select group and system data in selectors --- .../docs/ifcopenshell-python/selector_syntax.rst | 5 ++++- src/ifcopenshell-python/ifcopenshell/util/selector.py | 5 +++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/ifcopenshell-python/docs/ifcopenshell-python/selector_syntax.rst b/src/ifcopenshell-python/docs/ifcopenshell-python/selector_syntax.rst index fcc4f7cd7d..6893ddba95 100644 --- a/src/ifcopenshell-python/docs/ifcopenshell-python/selector_syntax.rst +++ b/src/ifcopenshell-python/docs/ifcopenshell-python/selector_syntax.rst @@ -183,8 +183,11 @@ Valid keys are: "``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." "``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." + "``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." "``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" diff --git a/src/ifcopenshell-python/ifcopenshell/util/selector.py b/src/ifcopenshell-python/ifcopenshell/util/selector.py index a2c831ca64..f1b00cf5e7 100644 --- a/src/ifcopenshell-python/ifcopenshell/util/selector.py +++ b/src/ifcopenshell-python/ifcopenshell/util/selector.py @@ -31,6 +31,7 @@ import ifcopenshell.util.geolocation import ifcopenshell.util.classification import ifcopenshell.util.schema import ifcopenshell.util.shape +import ifcopenshell.util.system from decimal import Decimal 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() elif key == "classification": 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"): if getattr(value, "ObjectPlacement", None): matrix = ifcopenshell.util.placement.get_local_placement(value.ObjectPlacement)