mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-19 22:50:21 +00:00
match elements when attribute is none and negation used
This commit is contained in:
@@ -189,7 +189,7 @@ class Selector:
|
|||||||
value = None
|
value = None
|
||||||
for element in elements:
|
for element in elements:
|
||||||
element_value = cls.get_element_value(element, key)
|
element_value = cls.get_element_value(element, key)
|
||||||
if element_value is None and value is not None:
|
if element_value is None and value is not None and "not" not in comparison:
|
||||||
continue
|
continue
|
||||||
if comparison and cls.filter_element(element, element_value, comparison, value):
|
if comparison and cls.filter_element(element, element_value, comparison, value):
|
||||||
results.append(element)
|
results.append(element)
|
||||||
|
|||||||
@@ -112,7 +112,7 @@ class TestSelector(test.bootstrap.IFC4):
|
|||||||
assert subject.Selector.parse(self.file, '.IfcElement[Name*="oba"]') == [element]
|
assert subject.Selector.parse(self.file, '.IfcElement[Name*="oba"]') == [element]
|
||||||
assert subject.Selector.parse(self.file, '.IfcElement[Name*="abc"]') == []
|
assert subject.Selector.parse(self.file, '.IfcElement[Name*="abc"]') == []
|
||||||
|
|
||||||
def test_comparing_if_value_does_not_exist(self):
|
def test_selecting_if_value_not_matching(self):
|
||||||
element_1 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
element_1 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||||
element_2 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
element_2 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||||
pset_1 = ifcopenshell.api.run("pset.add_pset", self.file, product=element_1, name="Foo_Bar")
|
pset_1 = ifcopenshell.api.run("pset.add_pset", self.file, product=element_1, name="Foo_Bar")
|
||||||
@@ -122,6 +122,11 @@ class TestSelector(test.bootstrap.IFC4):
|
|||||||
assert subject.Selector.parse(self.file, '.IfcElement[Foo_Bar.Foo != "Bar"]') == [element_2]
|
assert subject.Selector.parse(self.file, '.IfcElement[Foo_Bar.Foo != "Bar"]') == [element_2]
|
||||||
assert subject.Selector.parse(self.file, '.IfcElement[Foo_Bar.Foo != "BOO"]') == [element_1]
|
assert subject.Selector.parse(self.file, '.IfcElement[Foo_Bar.Foo != "BOO"]') == [element_1]
|
||||||
|
|
||||||
|
|
||||||
|
def test_selecting_when_attribute_is_none(self):
|
||||||
|
element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||||
|
assert subject.Selector.parse(self.file, '.IfcElement[PredefinedType !="non-existent predefined type"]') == [element]
|
||||||
|
|
||||||
def test_selecting_a_property_which_includes_non_standard_characters(self):
|
def test_selecting_a_property_which_includes_non_standard_characters(self):
|
||||||
element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||||
pset = ifcopenshell.api.run("pset.add_pset", self.file, product=element, name="a !%$§&/()?|*-+,€~#@µ^°a")
|
pset = ifcopenshell.api.run("pset.add_pset", self.file, product=element, name="a !%$§&/()?|*-+,€~#@µ^°a")
|
||||||
|
|||||||
Reference in New Issue
Block a user