mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-26 02:07:36 +00:00
Fix #1599. Bug where removing the last object in a container would have an error.
This commit is contained in:
@@ -11,12 +11,13 @@ class Usecase:
|
|||||||
|
|
||||||
def execute(self):
|
def execute(self):
|
||||||
contained_in_structure = self.settings["product"].ContainedInStructure
|
contained_in_structure = self.settings["product"].ContainedInStructure
|
||||||
|
if not contained_in_structure:
|
||||||
|
return
|
||||||
|
|
||||||
if contained_in_structure:
|
related_elements = list(contained_in_structure[0].RelatedElements)
|
||||||
related_elements = list(contained_in_structure[0].RelatedElements)
|
related_elements.remove(self.settings["product"])
|
||||||
related_elements.remove(self.settings["product"])
|
if related_elements:
|
||||||
if related_elements:
|
contained_in_structure[0].RelatedElements = related_elements
|
||||||
contained_in_structure[0].RelatedElements = related_elements
|
ifcopenshell.api.run("owner.update_owner_history", self.file, **{"element": contained_in_structure[0]})
|
||||||
ifcopenshell.api.run("owner.update_owner_history", self.file, **{"element": contained_in_structure[0]})
|
else:
|
||||||
else:
|
self.file.remove(contained_in_structure[0])
|
||||||
self.file.remove(contained_in_structure)
|
|
||||||
|
|||||||
Reference in New Issue
Block a user