Fix bug where related openings are not deleted when you delete a product

This commit is contained in:
Dion Moult
2021-05-12 22:20:58 +10:00
parent 35ceba2e88
commit beb813cb21
5 changed files with 30 additions and 6 deletions
@@ -22,5 +22,7 @@ class Usecase:
self.file, **{"product": self.settings["product"], "representation": representation}
)
ifcopenshell.api.run("geometry.remove_representation", self.file, **{"representation": representation})
for opening in self.settings["product"].HasOpenings or []:
ifcopenshell.api.run("void.remove_opening", self.file, opening=opening.RelatedOpeningElement)
# TODO: remove object placement and other relationships
self.file.remove(self.settings["product"])
@@ -1,3 +1,6 @@
import ifcopenshell.api
class Usecase:
def __init__(self, file, **settings):
self.file = file
@@ -15,6 +18,6 @@ class Usecase:
if rel.RelatingOpeningElement == self.settings["opening"]:
to_remove.append(rel)
break
self.file.remove(self.settings["opening"])
ifcopenshell.api.run("root.remove_product", self.file, product=self.settings["opening"])
for element in to_remove:
self.file.remove(element)