diff --git a/src/ifcopenshell-python/ifcopenshell/api/pset/remove_pset.py b/src/ifcopenshell-python/ifcopenshell/api/pset/remove_pset.py index e2d663cf8f..6f2cdfec05 100644 --- a/src/ifcopenshell-python/ifcopenshell/api/pset/remove_pset.py +++ b/src/ifcopenshell-python/ifcopenshell/api/pset/remove_pset.py @@ -41,6 +41,8 @@ class Usecase: properties = self.settings["pset"].HasProperties or [] elif self.settings["pset"].is_a("IfcQuantitySet"): properties = self.settings["pset"].Quantities or [] + elif self.settings["pset"].is_a() in ("IfcMaterialProperties", "IfcProfileProperties"): + properties = self.settings["pset"].Properties or [] for prop in properties: self.file.remove(prop) self.file.remove(self.settings["pset"]) diff --git a/src/ifcopenshell-python/test/api/pset/test_remove_pset.py b/src/ifcopenshell-python/test/api/pset/test_remove_pset.py index 4f5291a3ef..e06ebf1a86 100644 --- a/src/ifcopenshell-python/test/api/pset/test_remove_pset.py +++ b/src/ifcopenshell-python/test/api/pset/test_remove_pset.py @@ -29,6 +29,22 @@ class TestRemovePset(test.bootstrap.IFC4): assert len(self.file.by_type("IfcRelDefinesByProperties")) == 0 assert len(self.file.by_type("IfcPropertySet")) == 0 + def test_removing_material_psets(self): + element = self.file.createIfcMaterial() + pset = ifcopenshell.api.run("pset.add_pset", self.file, product=element, name="Foo_Bar") + assert len(element.HasProperties) == 1 + ifcopenshell.api.run("pset.remove_pset", self.file, product=element, pset=pset) + assert len(element.HasProperties) == 0 + assert len(self.file.by_type("IfcMaterialProperties")) == 0 + + def test_removing_profile_psets(self): + element = self.file.createIfcProfileDef() + pset = ifcopenshell.api.run("pset.add_pset", self.file, product=element, name="Foo_Bar") + assert len(element.HasProperties) == 1 + ifcopenshell.api.run("pset.remove_pset", self.file, product=element, pset=pset) + assert len(element.HasProperties) == 0 + assert len(self.file.by_type("IfcMaterialProperties")) == 0 + def test_only_unassigning_if_pset_is_used_by_other_elements(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")