mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-09 17:31:45 +00:00
sequence.remove_task to remove IfcRecurrencePattern
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user