get_pset() fix bug getting inherited psets with psets_only/qtos_only = True

This commit is contained in:
Andrej730
2024-04-10 15:22:22 +05:00
parent b77df1892c
commit ee7cf918ea
2 changed files with 11 additions and 5 deletions
@@ -94,11 +94,13 @@ def get_pset(
elif qtos_only and not pset.is_a("IfcElementQuantity"):
pset = None
if type_pset is not None:
if psets_only and not type_pset.is_a("IfcPropertySet"):
type_pset = None
elif qtos_only and not type_pset.is_a("IfcElementQuantity"):
type_pset = None
if type_pset is not None and not prop:
if psets_only or qtos_only:
type_pset_element = element.file.by_id(type_pset["id"])
if psets_only and not type_pset_element.is_a("IfcPropertySet"):
type_pset = None
elif qtos_only and not type_pset_element.is_a("IfcElementQuantity"):
type_pset = None
if pset is None and type_pset is None:
return
@@ -72,6 +72,10 @@ class TestGetPsetIFC4(test.bootstrap.IFC4):
ifcopenshell.api.run("pset.edit_pset", self.file, pset=pset, properties={"z": False})
assert subject.get_pset(element, "name2", "z") is False
# test filters with inherited psets
assert subject.get_pset(element, "name", psets_only=True) == result
assert subject.get_pset(element, "name", qtos_only=True) == None
def test_excluding_inherited_psets(self):
element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
type_element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWallType")