diff --git a/src/ifcopenshell-python/ifcopenshell/api/cost/copy_cost_schedule.py b/src/ifcopenshell-python/ifcopenshell/api/cost/copy_cost_schedule.py index 3101e820c2..126748af4c 100644 --- a/src/ifcopenshell-python/ifcopenshell/api/cost/copy_cost_schedule.py +++ b/src/ifcopenshell-python/ifcopenshell/api/cost/copy_cost_schedule.py @@ -45,5 +45,6 @@ def copy_cost_schedule( 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.unassign_control(file, cost_schedule, [duplicated_cost_item]) ifcopenshell.api.control.assign_control(file, new_schedule, [duplicated_cost_item]) return new_schedule diff --git a/src/ifcopenshell-python/test/api/cost/test_copy_cost_schedule.py b/src/ifcopenshell-python/test/api/cost/test_copy_cost_schedule.py index 119c24387e..cac94c320f 100644 --- a/src/ifcopenshell-python/test/api/cost/test_copy_cost_schedule.py +++ b/src/ifcopenshell-python/test/api/cost/test_copy_cost_schedule.py @@ -40,6 +40,9 @@ class TestCopyCostSchedule(test.bootstrap.IFC4): assert len(new_cost_items) == 2 assert len(new_cost_items.intersection(old_cost_items)) == 0 + # The copies should be removed from the original schedule. + assert set(ifcopenshell.util.cost.get_schedule_cost_items(schedule)) == old_cost_items + class TestCopyCostScheduleIFC2X3(test.bootstrap.IFC2X3, TestCopyCostSchedule): pass