From 83be26e1960346bceed6b78e0c7e1b6301d21676 Mon Sep 17 00:00:00 2001 From: myoualid Date: Sun, 8 Sep 2024 15:25:56 +0100 Subject: [PATCH] fix loading cost schedule webui from blender operator --- src/bonsai/bonsai/bim/data/webui/sioserver.py | 2 ++ src/bonsai/bonsai/core/cost.py | 3 +-- src/bonsai/bonsai/tool/cost.py | 5 +++-- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/bonsai/bonsai/bim/data/webui/sioserver.py b/src/bonsai/bonsai/bim/data/webui/sioserver.py index f61e1d3d41..91cec745e5 100644 --- a/src/bonsai/bonsai/bim/data/webui/sioserver.py +++ b/src/bonsai/bonsai/bim/data/webui/sioserver.py @@ -70,6 +70,8 @@ class WebNamespace(socketio.AsyncNamespace): await self.emit("gantt_data", {"blenderId": blenderId, "data": messages["gantt_data"]}, room=sid) if "demo_data" in messages: await self.emit("demo_data", {"blenderId": blenderId, "data": messages["demo_data"]}, room=sid) + if 'cost_items' in messages: + await self.emit("cost_items", {"blenderId": blenderId, "data": messages["cost_items"]}, room=sid) async def process_svg(self, file_path): def encode_image(filepath): diff --git a/src/bonsai/bonsai/core/cost.py b/src/bonsai/bonsai/core/cost.py index 0b5e4a30dc..b465ba0f8c 100644 --- a/src/bonsai/bonsai/core/cost.py +++ b/src/bonsai/bonsai/core/cost.py @@ -401,5 +401,4 @@ def add_currency(ifc: tool.Ifc, cost: tool.Cost) -> ifcopenshell.entity_instance def generate_cost_schedule_browser(cost: tool.Cost, cost_schedule: ifcopenshell.entity_instance) -> bpy.types.Panel: - cost_schedule_data = cost.create_cost_schedule_json(cost_schedule) - return cost.generate_cost_schedule_browser(cost_schedule_data) + return cost.generate_cost_schedule_browser(cost_schedule) diff --git a/src/bonsai/bonsai/tool/cost.py b/src/bonsai/bonsai/tool/cost.py index 822e20d78c..ffc6943cae 100644 --- a/src/bonsai/bonsai/tool/cost.py +++ b/src/bonsai/bonsai/tool/cost.py @@ -854,7 +854,8 @@ class Cost(bonsai.core.tool.Cost): return {"id": unit.id(), "name": unit.Currency} @classmethod - def generate_cost_schedule_browser(cls, cost_schedule_data: list[dict[str, Any]]) -> None: + def generate_cost_schedule_browser(cls, cost_chedule) -> None: if not bpy.context.scene.WebProperties.is_connected: bpy.ops.bim.connect_websocket_server(page="costing") - tool.Web.send_webui_data(data=cost_schedule_data, data_key="cost_items", event="cost_items") + cost_schedule_data = cls.create_cost_schedule_json(cost_chedule) + tool.Web.send_webui_data(data={"cost_items": cost_schedule_data, "cost_schedule_id": cost_chedule.id()}, data_key="cost_items", event="cost_items")