Minor fixes, and IfcCSV now uses pandas to import ODS/XLSX for more robust importing.

This commit is contained in:
Dion Moult
2023-08-26 18:24:48 +10:00
parent 2298201e50
commit 628005333d
3 changed files with 27 additions and 36 deletions
@@ -78,7 +78,7 @@ class TestGetElementValue(test.bootstrap.IFC4):
assert subject.get_element_value(element, "material.item.Name.0") == "L1"
assert subject.get_element_value(element, "material.item.Name.1") == "L2"
assert subject.get_element_value(element, '"material"."item"."Name"') == ["L1", "L2"]
assert subject.get_element_value(element, 'r"material"."item"."Name"') == ["L1", "L2"]
assert subject.get_element_value(element, 'material."item"."Name"') == ["L1", "L2"]
# Provide shortform for convenience
assert subject.get_element_value(element, "mat.i.Name") == ["L1", "L2"]
@@ -86,7 +86,7 @@ class TestGetElementValue(test.bootstrap.IFC4):
element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
assert subject.get_element_value(element, "material.item.Name.0") is None
def test_selceting_a_list_item_that_fails_silently(self):
def test_selecting_a_list_item_that_fails_silently(self):
element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
material = ifcopenshell.api.run("material.add_material", self.file, name="CON01")
material2 = ifcopenshell.api.run("material.add_material", self.file, name="CON02")
@@ -99,6 +99,24 @@ class TestGetElementValue(test.bootstrap.IFC4):
assert subject.get_element_value(element, "material.item.Name.0") == "L1"
assert subject.get_element_value(element, "material.item.Name.1") is None
def test_selecting_a_pset(self):
element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
element2 = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
pset = ifcopenshell.api.run("pset.add_pset", self.file, product=element, name="Foobar")
ifcopenshell.api.run("pset.edit_pset", self.file, pset=pset, properties={"Foo": "Bar"})
assert subject.get_element_value(element, "Foobar.Foo") == "Bar"
assert subject.get_element_value(element, "Foobar./F.*/") == "Bar"
assert subject.get_element_value(element, "/Foo.*/./F.*/") == "Bar"
ifcopenshell.api.run("pset.edit_pset", self.file, pset=pset, properties={"Baz": 123})
assert subject.get_element_value(element, "/Foo.*/./B.*/") == 123
assert subject.get_element_value(element, "/Foo.*/./.*/") == ["Bar", 123]
ifcopenshell.api.run("pset.edit_pset", self.file, pset=pset, properties={"Bay": 123.3})
assert subject.get_element_value(element, "/Foo.*/./B.*/") == [123, 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.get_element_value(element, "/Pset_.*Common/.Status") == ["New"]
assert subject.get_element_value(element, "/Pset_.*Common/.Status.0") == "New"
class TestFilterElements(test.bootstrap.IFC4):
def test_selecting_by_globalid(self):