control.assign_control to support batching

This commit is contained in:
Andrej730
2025-09-09 11:14:57 +05:00
parent fcb263f59a
commit abfb56350d
23 changed files with 104 additions and 50 deletions
@@ -138,7 +138,7 @@ def add_task(
task.Identification = identification
task.IsMilestone = False
if work_schedule:
ifcopenshell.api.control.assign_control(file, work_schedule, task)
ifcopenshell.api.control.assign_control(file, work_schedule, [task])
elif parent_task:
rel = ifcopenshell.api.nest.assign_object(
file,
@@ -75,7 +75,7 @@ def add_work_calendar(
# We associate the calendar with the construction root task. All
# subtasks underneath the construction work task will also inherit
# this calendar by default (though you can override them).
ifcopenshell.api.control.assign_control(model, relating_control=calendar, related_object=task)
ifcopenshell.api.control.assign_control(model, relating_control=calendar, related_objects=[task])
"""
work_calendar = ifcopenshell.api.root.create_entity(
file,
@@ -47,5 +47,5 @@ def copy_work_schedule(
duplicated_tasks = ifcopenshell.api.sequence.duplicate_task(file, task)[1]
# All other nested items are not connected to the work schedule explicitly.
duplicated_task = duplicated_tasks[0]
ifcopenshell.api.control.assign_control(file, new_schedule, duplicated_task)
ifcopenshell.api.control.assign_control(file, new_schedule, [duplicated_task])
return new_schedule
@@ -79,7 +79,7 @@ class Usecase:
assert isinstance(res, list)
current, duplicate = res
ifcopenshell.api.control.assign_control(
self.file, relating_control=baseline_work_schedule, related_object=duplicate[0]
self.file, relating_control=baseline_work_schedule, related_objects=[duplicate[0]]
)
for i, task in enumerate(current):
self.create_baseline_reference(task, duplicate[i])