sequence.remove_task to remove IfcRecurrencePattern

This commit is contained in:
Andrej730
2024-06-10 14:01:52 +05:00
parent d56da70cae
commit 6552463ed9
3 changed files with 26 additions and 3 deletions
@@ -19,6 +19,7 @@
import ifcopenshell
import ifcopenshell.api
import ifcopenshell.api.nest
import ifcopenshell.api.sequence
import ifcopenshell.util.element
@@ -63,8 +64,10 @@ def remove_task(file: ifcopenshell.file, task: ifcopenshell.entity_instance) ->
definitions=[settings["task"]],
relating_context=file.by_type("IfcContext")[0],
)
if settings["task"].TaskTime:
file.remove(settings["task"].TaskTime)
if task_time := settings["task"].TaskTime:
if task_time.is_a("IfcTaskTimeRecurring"):
ifcopenshell.api.sequence.unassign_recurrence_pattern(file, task_time.Recurrence)
file.remove(task_time)
# Handle IfcRelNests.
if rels := settings["task"].IsNestedBy:
@@ -22,7 +22,10 @@ def unassign_recurrence_pattern(file: ifcopenshell.file, recurrence_pattern: ifc
"""Unassigns a recurrence pattern
Note that a recurring task time must have a recurrence pattern, so if
you remove it, be sure to clean up after your
you remove it, be sure to clean up after this API call
(e.g. remove IfcTaskTimeRecurring entity
or assign a different recurrence patern to it
or replace IfcTaskTimeRecurring with IfcTaskTime).
:param recurrence_pattern: The IfcRecurrencePattern to remove.
:type recurrence_pattern: ifcopenshell.entity_instance