Files
IfcOpenShell/src/ifcopenshell-python/ifcopenshell/api/spatial/remove_container.py
T

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

21 lines
695 B
Python
Raw Normal View History

import ifcopenshell
class Usecase:
2021-03-25 00:54:42 +01:00
def __init__(self, file, settings={}):
self.file = file
self.settings = {"product": None}
for key, value in settings.items():
self.settings[key] = value
def execute(self):
contained_in_structure = self.settings["product"].ContainedInStructure
if contained_in_structure:
related_elements = list(contained_in_structure[0].RelatedElements)
related_elements.remove(self.settings["product"])
if related_elements:
contained_in_structure[0].RelatedElements = related_elements
else:
self.file.remove(contained_in_structure)