diff --git a/src/ifcopenshell-python/ifcopenshell/util/selector.py b/src/ifcopenshell-python/ifcopenshell/util/selector.py index 4723ef5903..d7861d3f90 100644 --- a/src/ifcopenshell-python/ifcopenshell/util/selector.py +++ b/src/ifcopenshell-python/ifcopenshell/util/selector.py @@ -267,7 +267,9 @@ class Selector: elif value.is_a("IfcMaterialConstituentSet"): value = value.MaterialConstituents elif key == "container": - value = ifcopenshell.util.element.get_container(element) + value = ifcopenshell.util.element.get_container(value) + elif key == "class": + value = value.is_a() elif isinstance(value, ifcopenshell.entity_instance): attribute = value.get_info().get(key, None) diff --git a/src/ifcopenshell-python/test/util/test_selector.py b/src/ifcopenshell-python/test/util/test_selector.py index ec6368ae8f..b1e6470196 100644 --- a/src/ifcopenshell-python/test/util/test_selector.py +++ b/src/ifcopenshell-python/test/util/test_selector.py @@ -23,6 +23,11 @@ import ifcopenshell.util.selector as subject class TestGetElementValue(test.bootstrap.IFC4): + def test_selecting_an_elements_class_or_id_using_a_query(self): + element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall") + assert subject.get_element_value(element, "class") == "IfcWall" + assert subject.get_element_value(element, "id") == element.id() + def test_selecting_an_elements_value_using_a_query(self): element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall") element.Name = "Foobar"