remove_work_schedule to unassign a work schedule from a work plan #4819

This commit is contained in:
Andrej730
2024-06-07 17:14:03 +05:00
parent 5c41baeaf1
commit 61c2a2c6c6
2 changed files with 69 additions and 0 deletions
@@ -18,6 +18,7 @@
import ifcopenshell
import ifcopenshell.api
import ifcopenshell.api.aggregate
import ifcopenshell.util.element
@@ -54,6 +55,7 @@ def remove_work_schedule(file: ifcopenshell.file, work_schedule: ifcopenshell.en
definitions=[settings["work_schedule"]],
relating_context=file.by_type("IfcContext")[0],
)
if settings["work_schedule"].Declares:
for rel in settings["work_schedule"].Declares:
for work_schedule in rel.RelatedObjects:
@@ -62,6 +64,11 @@ def remove_work_schedule(file: ifcopenshell.file, work_schedule: ifcopenshell.en
file,
work_schedule=work_schedule,
)
# Unassign from work plans.
if settings["work_schedule"].Decomposes:
ifcopenshell.api.aggregate.unassign_object(file, [settings["work_schedule"]])
for inverse in file.get_inverse(settings["work_schedule"]):
if inverse.is_a("IfcRelDefinesByObject"):
if inverse.RelatingObject == settings["work_schedule"] or len(inverse.RelatedObjects) == 1: