mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-10 17:58:20 +00:00
#2082 You can now filter by metadata existence in the selector syntax
This commit is contained in:
@@ -33,6 +33,13 @@ class TestSelector(test.bootstrap.IFC4):
|
||||
ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcSlab")
|
||||
assert subject.Selector.parse(self.file, f"#{element.GlobalId}") == [element]
|
||||
|
||||
def test_selecting_by_attribute_existence(self):
|
||||
element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
element.Name = "Foobar"
|
||||
ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcSlab")
|
||||
assert subject.Selector.parse(self.file, '.IfcElement[Name]') == [element]
|
||||
assert subject.Selector.parse(self.file, '.IfcElement[Description]') == []
|
||||
|
||||
def test_selecting_by_attribute(self):
|
||||
element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
element.Name = "Foobar"
|
||||
@@ -40,6 +47,13 @@ class TestSelector(test.bootstrap.IFC4):
|
||||
assert subject.Selector.parse(self.file, '.IfcElement[Name="Foobar"]') == [element]
|
||||
assert subject.Selector.parse(self.file, '.IfcElement[Name="Foobaz"]') == []
|
||||
|
||||
def test_selecting_by_property_existence(self):
|
||||
element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
pset = ifcopenshell.api.run("pset.add_pset", self.file, product=element, name="Foo_Bar")
|
||||
ifcopenshell.api.run("pset.edit_pset", self.file, pset=pset, properties={"Foo": "Bar"})
|
||||
assert subject.Selector.parse(self.file, '.IfcElement[Foo_Bar.Foo]') == [element]
|
||||
assert subject.Selector.parse(self.file, '.IfcElement[Foo_Bar.Fox]') == []
|
||||
|
||||
def test_selecting_by_string_property(self):
|
||||
element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
pset = ifcopenshell.api.run("pset.add_pset", self.file, product=element, name="Foo_Bar")
|
||||
|
||||
Reference in New Issue
Block a user