From 84f6632c13e4ddcd8d7ad89167f6c5a29517687a Mon Sep 17 00:00:00 2001 From: Andrej730 Date: Wed, 23 Jul 2025 18:36:51 +0500 Subject: [PATCH] Reuse assign_control instead of creating IfcRelAssignsToControls --- .../ifcopenshell/api/cost/add_cost_item.py | 12 ++---------- .../ifcopenshell/api/sequence/add_task.py | 12 ++---------- 2 files changed, 4 insertions(+), 20 deletions(-) diff --git a/src/ifcopenshell-python/ifcopenshell/api/cost/add_cost_item.py b/src/ifcopenshell-python/ifcopenshell/api/cost/add_cost_item.py index 34e20aa63a..86881265af 100644 --- a/src/ifcopenshell-python/ifcopenshell/api/cost/add_cost_item.py +++ b/src/ifcopenshell-python/ifcopenshell/api/cost/add_cost_item.py @@ -16,9 +16,9 @@ # You should have received a copy of the GNU Lesser General Public License # along with IfcOpenShell. If not, see . +import ifcopenshell.api.control import ifcopenshell.api.root import ifcopenshell.api.nest -import ifcopenshell.api.owner import ifcopenshell.guid from typing import Optional @@ -59,15 +59,7 @@ def add_cost_item( cost_item_ = ifcopenshell.api.root.create_entity(file, ifc_class="IfcCostItem") if cost_schedule: - file.create_entity( - "IfcRelAssignsToControl", - **{ - "GlobalId": ifcopenshell.guid.new(), - "OwnerHistory": ifcopenshell.api.owner.create_owner_history(file), - "RelatedObjects": [cost_item_], - "RelatingControl": cost_schedule, - }, - ) + ifcopenshell.api.control.assign_control(file, cost_schedule, cost_item_) elif cost_item: ifcopenshell.api.nest.assign_object(file, related_objects=[cost_item_], relating_object=cost_item) return cost_item_ diff --git a/src/ifcopenshell-python/ifcopenshell/api/sequence/add_task.py b/src/ifcopenshell-python/ifcopenshell/api/sequence/add_task.py index f6fa8feb8e..03cf6cb5eb 100644 --- a/src/ifcopenshell-python/ifcopenshell/api/sequence/add_task.py +++ b/src/ifcopenshell-python/ifcopenshell/api/sequence/add_task.py @@ -16,9 +16,9 @@ # You should have received a copy of the GNU Lesser General Public License # along with IfcOpenShell. If not, see . +import ifcopenshell.api.control import ifcopenshell.api.root import ifcopenshell.api.nest -import ifcopenshell.api.owner import ifcopenshell import ifcopenshell.guid from typing import Optional @@ -139,15 +139,7 @@ def add_task( task.Identification = identification task.IsMilestone = False if work_schedule: - file.create_entity( - "IfcRelAssignsToControl", - **{ - "GlobalId": ifcopenshell.guid.new(), - "OwnerHistory": ifcopenshell.api.owner.create_owner_history(file), - "RelatedObjects": [task], - "RelatingControl": work_schedule, - } - ) + ifcopenshell.api.control.assign_control(file, work_schedule, task) elif parent_task: rel = ifcopenshell.api.nest.assign_object( file,