From 2e21fc5a98aa409c01912fa0df7009338d7987e4 Mon Sep 17 00:00:00 2001 From: Andrej730 Date: Sat, 18 Jul 2026 21:21:54 +0500 Subject: [PATCH] assign_cost_item_quantity: fix indendation and missing `values` (de65e50) `values` dictionary was missing and variables were never collected to it, so `FormulaEvaluator(values)` was always resulting in missing variable error. --- .../api/cost/assign_cost_item_quantity.py | 22 ++++++++++--------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/src/ifcopenshell-python/ifcopenshell/api/cost/assign_cost_item_quantity.py b/src/ifcopenshell-python/ifcopenshell/api/cost/assign_cost_item_quantity.py index a3e2e96265..c699bb1ebb 100644 --- a/src/ifcopenshell-python/ifcopenshell/api/cost/assign_cost_item_quantity.py +++ b/src/ifcopenshell-python/ifcopenshell/api/cost/assign_cost_item_quantity.py @@ -150,20 +150,22 @@ class Usecase: collector.visit(tree) variables = collector.variables + values: dict[str, float | None] = {} for variable in variables: getter = self.get_value_from_pset if "." in variable else self.get_value_from_qset value = getter(product, variable) + values[variable] = value - if value is None: - print( - f"WARNING: Variable '{variable}' in product '{product.Name}' " - f"is missing (None). Check Pset/Qset or property name." - ) - elif value == 0: - print( - f"WARNING: Variable '{variable}' in product '{product.Name}' " - f"has value 0. Verify if this is correct." - ) + if value is None: + print( + f"WARNING: Variable '{variable}' in product '{product.Name}' " + f"is missing (None). Check Pset/Qset or property name." + ) + elif value == 0: + print( + f"WARNING: Variable '{variable}' in product '{product.Name}' " + f"has value 0. Verify if this is correct." + ) evaluator = FormulaEvaluator(values) result = evaluator.visit(tree.body)