From 8a31e8d149f34bf829630881654294760fdbbdfb Mon Sep 17 00:00:00 2001 From: Andrej730 Date: Thu, 21 Nov 2024 16:04:22 +0500 Subject: [PATCH] Auto update cost item rates when enabling editing non-sor cost schedule There was an issue that it wouldn't load until you manually select it in the "Cost Item Rates" enum - otherwise items didn't appear the first time cost schedule opened and didn't not update when you makes changes to the active schedule of rates. --- src/bonsai/bonsai/core/cost.py | 2 ++ src/bonsai/bonsai/tool/cost.py | 8 ++++++++ 2 files changed, 10 insertions(+) diff --git a/src/bonsai/bonsai/core/cost.py b/src/bonsai/bonsai/core/cost.py index 4ba7f69940..7ac985ac46 100644 --- a/src/bonsai/bonsai/core/cost.py +++ b/src/bonsai/bonsai/core/cost.py @@ -54,6 +54,8 @@ def enable_editing_cost_items(cost: tool.Cost, cost_schedule: ifcopenshell.entit cost.enable_editing_cost_items(cost_schedule) cost.load_active_schedule_columns() cost.load_cost_schedule_tree() + if not cost.is_active_schedule_of_rates() and (schedule_of_rates := cost.get_active_schedule_of_rates()): + cost.load_schedule_of_rates_tree(schedule_of_rates) cost.play_sound() diff --git a/src/bonsai/bonsai/tool/cost.py b/src/bonsai/bonsai/tool/cost.py index d9664898c7..2155c1d4ac 100644 --- a/src/bonsai/bonsai/tool/cost.py +++ b/src/bonsai/bonsai/tool/cost.py @@ -551,6 +551,14 @@ class Cost(bonsai.core.tool.Cost): props = bpy.context.scene.BIMCostProperties props.columns.remove(props.columns.find(name)) + @classmethod + def get_active_schedule_of_rates(cls) -> Union[ifcopenshell.entity_instance, None]: + props = bpy.context.scene.BIMCostProperties + schedule_id = tool.Blender.get_enum_safe(props, "schedule_of_rates") + if schedule_id is None: + return + return tool.Ifc.get().by_id(int(schedule_id)) + @classmethod def expand_cost_item_rate(cls, cost_item: ifcopenshell.entity_instance) -> None: props = bpy.context.scene.BIMCostProperties