From 6c82e6f88965ce60539cfdffdc3a04a9b594a322 Mon Sep 17 00:00:00 2001 From: Sigma Dimensions <79010126+myoualid@users.noreply.github.com> Date: Fri, 10 Feb 2023 21:28:22 +0100 Subject: [PATCH] Fix assign cost value usecase --- .../ifcopenshell/api/cost/assign_cost_value.py | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/ifcopenshell-python/ifcopenshell/api/cost/assign_cost_value.py b/src/ifcopenshell-python/ifcopenshell/api/cost/assign_cost_value.py index 31f119bbab..2287be40a3 100644 --- a/src/ifcopenshell-python/ifcopenshell/api/cost/assign_cost_value.py +++ b/src/ifcopenshell-python/ifcopenshell/api/cost/assign_cost_value.py @@ -49,7 +49,7 @@ class Usecase: rate_tables = ifcopenshell.api.run("cost.add_cost_schedule", model, predefined_type="SCHEDULEOFRATES") rate = ifcopenshell.api.run("cost.add_cost_item", model, cost_schedule=schedule) - value = ifcopenshell.api.run("cost.add_cost_value", model, parent=item) + value = ifcopenshell.api.run("cost.add_cost_value", model, parent=rate) ifcopenshell.api.run("cost.edit_cost_value", model, cost_value=value, attributes={"AppliedValue": 5.0}) @@ -64,9 +64,15 @@ class Usecase: self.settings = {"cost_item": cost_item, "cost_rate": cost_rate} def execute(self): - for cost_value in self.settings["cost_item"].CostValues: - ifcopenshell.api.run( - "cost.remove_cost_item_value", self.file, parent=self.settings["cost_item"], cost_value=cost_value - ) + if self.settings["cost_item"].CostValues: + [ + ifcopenshell.api.run( + "cost.remove_cost_item_value", + self.file, + parent=self.settings["cost_item"], + cost_value=cost_value, + ) + for cost_value in self.settings["cost_item"].CostValues + ] # This is an assumption, and not part of the official IFC documentation self.settings["cost_item"].CostValues = self.settings["cost_rate"].CostValues