mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-09 17:31:45 +00:00
remove_work_plan - unassign work schedules #4819
This commit is contained in:
@@ -20,6 +20,7 @@ import ifcopenshell
|
||||
import ifcopenshell.api
|
||||
|
||||
|
||||
# TODO: rename to assign_work_plan for consistency
|
||||
def assign_workplan(
|
||||
file: ifcopenshell.file, work_schedule: ifcopenshell.entity_instance, work_plan: ifcopenshell.entity_instance
|
||||
) -> ifcopenshell.entity_instance:
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
|
||||
import ifcopenshell
|
||||
import ifcopenshell.api
|
||||
import ifcopenshell.api.aggregate
|
||||
import ifcopenshell.util.element
|
||||
|
||||
|
||||
@@ -44,13 +45,17 @@ def remove_work_plan(file: ifcopenshell.file, work_plan: ifcopenshell.entity_ins
|
||||
"""
|
||||
settings = {"work_plan": work_plan}
|
||||
|
||||
# TODO: do a deep purge
|
||||
ifcopenshell.api.run(
|
||||
"project.unassign_declaration",
|
||||
file,
|
||||
definitions=[settings["work_plan"]],
|
||||
relating_context=file.by_type("IfcContext")[0],
|
||||
)
|
||||
|
||||
related_objects = [obj for rel in work_plan.IsDecomposedBy for obj in rel.RelatedObjects]
|
||||
if related_objects:
|
||||
ifcopenshell.api.aggregate.unassign_object(file, related_objects)
|
||||
|
||||
history = settings["work_plan"].OwnerHistory
|
||||
file.remove(settings["work_plan"])
|
||||
if history:
|
||||
|
||||
Reference in New Issue
Block a user