diff --git a/src/bonsai/bonsai/bim/module/cost/data.py b/src/bonsai/bonsai/bim/module/cost/data.py index c5274b2c15..feee0a4c64 100644 --- a/src/bonsai/bonsai/bim/module/cost/data.py +++ b/src/bonsai/bonsai/bim/module/cost/data.py @@ -76,7 +76,7 @@ class CostSchedulesData: filepaths[schedule_id] = reference.Location except ValueError: pass - + return filepaths @classmethod diff --git a/src/bonsai/bonsai/bim/module/cost/operator.py b/src/bonsai/bonsai/bim/module/cost/operator.py index 5f61aab9c4..169b712246 100644 --- a/src/bonsai/bonsai/bim/module/cost/operator.py +++ b/src/bonsai/bonsai/bim/module/cost/operator.py @@ -25,7 +25,6 @@ import bonsai.tool as tool from bpy_extras.io_utils import ImportHelper, ExportHelper import bonsai.tool as tool import bonsai.core.cost as core -from bonsai.bim.module.cost.data import CostSchedulesData from pathlib import Path from typing import get_args, TYPE_CHECKING, Literal @@ -103,7 +102,6 @@ class EnableEditingCostItems(bpy.types.Operator, tool.Ifc.Operator): def _execute(self, context): core.enable_editing_cost_items(tool.Cost, cost_schedule=tool.Ifc.get().by_id(self.cost_schedule)) - CostSchedulesData.is_loaded = False class DisableEditingCostSchedule(bpy.types.Operator, tool.Ifc.Operator): @@ -569,30 +567,29 @@ class ImportCostScheduleCsv(bpy.types.Operator, ImportHelper, tool.Ifc.Operator) return True def _execute(self, context): - + store_path = self.filepath if self.use_relative_path: store_path = tool.Ifc.get_uri(self.filepath, use_relative_path=True) - + resolved_path = Path(tool.Ifc.resolve_uri(self.filepath)) if not resolved_path.exists(): self.report({"ERROR"}, f"File does not exist: '{store_path}' (resolved to '{resolved_path}')") return {"CANCELLED"} - + cost_schedule = core.import_cost_schedule_csv(tool.Cost, str(resolved_path), self.is_schedule_of_rates) if cost_schedule: core.add_csv_filepath(tool.Cost, store_path, self.is_schedule_of_rates, cost_schedule) - CostSchedulesData.is_loaded = False - return {"FINISHED"} return {"CANCELLED"} - + def draw(self, context): row = self.layout.row() row.prop(self, "is_schedule_of_rates") row = self.layout.row() row.prop(self, "use_relative_path") + class RefreshCostScheduleCsv(bpy.types.Operator, tool.Ifc.Operator): bl_idname = "bim.refresh_cost_schedule_csv" bl_label = "Refresh Cost Schedule CSV" @@ -605,18 +602,16 @@ class RefreshCostScheduleCsv(bpy.types.Operator, tool.Ifc.Operator): if not props.active_cost_schedule_id: cls.poll_message_set("No active cost schedule") return False - + file_path = tool.Cost.get_cost_schedule_csv_filepath(props.active_cost_schedule_id) if not file_path: cls.poll_message_set("No CSV file associated with this cost schedule") return False - + return True def _execute(self, context): core.refresh_cost_schedule_csv(tool.Cost) - CostSchedulesData.is_loaded = False - return {"FINISHED"} diff --git a/src/bonsai/bonsai/bim/module/cost/prop.py b/src/bonsai/bonsai/bim/module/cost/prop.py index 9ecea280ce..3ce30e665e 100644 --- a/src/bonsai/bonsai/bim/module/cost/prop.py +++ b/src/bonsai/bonsai/bim/module/cost/prop.py @@ -174,6 +174,7 @@ class CostItemQuantity(PropertyGroup): unit_symbol: str total_cost_quantity: float + class CostItemType(PropertyGroup): name: StringProperty(name="Name") ifc_definition_id: IntProperty(name="IFC Definition ID") diff --git a/src/bonsai/bonsai/bim/module/cost/ui.py b/src/bonsai/bonsai/bim/module/cost/ui.py index dd7cb4c34b..f02ae3eabd 100644 --- a/src/bonsai/bonsai/bim/module/cost/ui.py +++ b/src/bonsai/bonsai/bim/module/cost/ui.py @@ -76,10 +76,10 @@ class BIM_PT_cost_schedules(Panel): col = row0.column() col.label(text="Linked CSV:") row_1 = col.row(align=True) - + csv_filepaths = CostSchedulesData.data["csv_filepaths"] file_path = csv_filepaths.get(self.props.active_cost_schedule_id) - + if file_path: row_1.label(text=file_path) row_1.operator("bim.refresh_cost_schedule_csv", icon="FILE_REFRESH", text="") diff --git a/src/bonsai/bonsai/core/cost.py b/src/bonsai/bonsai/core/cost.py index 03dff47a7d..62a72a0056 100644 --- a/src/bonsai/bonsai/core/cost.py +++ b/src/bonsai/bonsai/core/cost.py @@ -18,8 +18,6 @@ from __future__ import annotations from typing import TYPE_CHECKING, Optional, Union, Literal -import os -from bonsai.bim.module.cost.data import CostSchedulesData if TYPE_CHECKING: import bpy @@ -345,7 +343,6 @@ def import_cost_schedule_csv( cost: type[tool.Cost], resolved_path: str, is_schedule_of_rates: bool ) -> ifcopenshell.entity_instance: - cost_schedule = cost.import_cost_schedule_csv(resolved_path, is_schedule_of_rates) return cost_schedule @@ -359,16 +356,10 @@ def remove_csv_filepath(cost: type[tool.Cost], cost_schedule) -> None: def refresh_cost_schedule_csv(cost: type[tool.Cost]) -> Optional[str]: - - cost.delete_all_cost_items() cost.refresh_cost_schedule_csv() cost.load_cost_schedule_tree() - CostSchedulesData.is_loaded = False - - return None - def add_cost_column(cost: type[tool.Cost], name: str) -> None: cost.add_cost_column(name) @@ -470,9 +461,3 @@ def add_currency(ifc: type[tool.Ifc], cost: type[tool.Cost]) -> ifcopenshell.ent def generate_cost_schedule_browser(cost: type[tool.Cost], cost_schedule: ifcopenshell.entity_instance) -> None: 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 afcc157158..e1c5ab1db4 100644 --- a/src/bonsai/bonsai/tool/cost.py +++ b/src/bonsai/bonsai/tool/cost.py @@ -603,12 +603,12 @@ class Cost(bonsai.core.tool.Cost): ), None, ) - + if not cost_docs_document: cost_docs_document = ifcopenshell.api.document.add_information(ifc_file) cost_docs_document.Name = "BBIM_Cost_Documents" cost_docs_document.Description = "Bonsai internal document containing references to cost CSV files" - + return cost_docs_document @classmethod @@ -1097,6 +1097,3 @@ class Cost(bonsai.core.tool.Cost): if results["quantity_type"] == "IfcQuantityCount": results["unit_symbol"] = "U" return results - - -