From f523870b578ee5336e14547bccc7676fcfe1a165 Mon Sep 17 00:00:00 2001 From: Dion Moult Date: Tue, 15 Aug 2023 09:55:48 +1000 Subject: [PATCH] Fix #3584. Support matching enumerated properties in new facet selector. --- src/ifcopenshell-python/ifcopenshell/util/selector.py | 4 +++- src/ifcopenshell-python/test/util/test_selector.py | 3 +++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/ifcopenshell-python/ifcopenshell/util/selector.py b/src/ifcopenshell-python/ifcopenshell/util/selector.py index f44160fbf6..2f08dc4049 100644 --- a/src/ifcopenshell-python/ifcopenshell/util/selector.py +++ b/src/ifcopenshell-python/ifcopenshell/util/selector.py @@ -294,7 +294,9 @@ class FacetTransformer(lark.Transformer): return False def compare(self, element_value, comparison, value): - if isinstance(value, str): + if isinstance(element_value, (list, tuple)): + return any(self.compare(ev, comparison, value) for ev in element_value) + elif isinstance(value, str): if isinstance(element_value, int): value = int(value) elif isinstance(element_value, float): diff --git a/src/ifcopenshell-python/test/util/test_selector.py b/src/ifcopenshell-python/test/util/test_selector.py index 0ff7227b47..67749417bd 100644 --- a/src/ifcopenshell-python/test/util/test_selector.py +++ b/src/ifcopenshell-python/test/util/test_selector.py @@ -137,6 +137,9 @@ class TestFilterElements(test.bootstrap.IFC4): ifcopenshell.api.run("pset.edit_pset", self.file, pset=pset, properties={"Baz": 123}) assert subject.filter_elements(self.file, "IfcWall, Foobar.Baz=123") == {element} ifcopenshell.api.run("pset.edit_pset", self.file, pset=pset, properties={"Bay": 123.3}) + pset = ifcopenshell.api.run("pset.add_pset", self.file, product=element, name="Pset_WallCommon") + ifcopenshell.api.run("pset.edit_pset", self.file, pset=pset, properties={"Status": ["New"]}) + assert subject.filter_elements(self.file, "IfcWall, Pset_WallCommon.Status=New") == {element} def test_selecting_by_classification(self): project = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcProject")