mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-09 17:31:45 +00:00
cost.copy_cost_schedule #6901
A feature allowing duplicate existing IfcCostSchedule - either from API or from Bonsai UI Button location in Bonsai - https://files.catbox.moe/ct058q.png
This commit is contained in:
@@ -34,6 +34,7 @@ from .assign_cost_value import assign_cost_value
|
||||
from .calculate_cost_item_resource_value import calculate_cost_item_resource_value
|
||||
from .copy_cost_item import copy_cost_item
|
||||
from .copy_cost_item_values import copy_cost_item_values
|
||||
from .copy_cost_schedule import copy_cost_schedule
|
||||
from .edit_cost_item import edit_cost_item
|
||||
from .edit_cost_item_quantity import edit_cost_item_quantity
|
||||
from .edit_cost_schedule import edit_cost_schedule
|
||||
@@ -57,6 +58,7 @@ __all__ = [
|
||||
"calculate_cost_item_resource_value",
|
||||
"copy_cost_item",
|
||||
"copy_cost_item_values",
|
||||
"copy_cost_schedule",
|
||||
"edit_cost_item",
|
||||
"edit_cost_item_quantity",
|
||||
"edit_cost_schedule",
|
||||
|
||||
@@ -0,0 +1,48 @@
|
||||
# IfcOpenShell - IFC toolkit and geometry engine
|
||||
# Copyright (C) 2021 Dion Moult <dion@thinkmoult.com>
|
||||
#
|
||||
# This file is part of IfcOpenShell.
|
||||
#
|
||||
# IfcOpenShell is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU Lesser General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# IfcOpenShell is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU Lesser General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Lesser General Public License
|
||||
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import ifcopenshell.api.control
|
||||
import ifcopenshell.api.cost
|
||||
import ifcopenshell.util.element
|
||||
|
||||
|
||||
def copy_cost_schedule(
|
||||
file: ifcopenshell.file, cost_schedule: ifcopenshell.entity_instance
|
||||
) -> ifcopenshell.entity_instance:
|
||||
"""Copy a cost schedule.
|
||||
|
||||
:param cost_schedule: IfcCostSchedule to copy.
|
||||
:return: The duplicated IfcCostSchedule entity
|
||||
|
||||
Example:
|
||||
|
||||
.. code:: python
|
||||
|
||||
schedule = ifcopenshell.api.cost.add_cost_schedule(model)
|
||||
new_schedule = ifcopenshell.api.cost.copy_cost_schedule(schedule)
|
||||
"""
|
||||
new_schedule = ifcopenshell.util.element.copy(file, cost_schedule)
|
||||
|
||||
for rel in cost_schedule.Controls:
|
||||
for cost_item in rel.RelatedObjects:
|
||||
duplicated_cost_item = ifcopenshell.api.cost.copy_cost_item(file, cost_item)
|
||||
if isinstance(duplicated_cost_item, list):
|
||||
# All other nested items are not connected to the cost schedule explicitly.
|
||||
duplicated_cost_item = duplicated_cost_item[0]
|
||||
ifcopenshell.api.control.assign_control(file, new_schedule, duplicated_cost_item)
|
||||
return new_schedule
|
||||
Reference in New Issue
Block a user