See #6570. Now it is possible to remove the csv cost file link.

This is a followup to that issue. In this particular case, a remove csv link button is added next to the refresh csv link button.
This commit is contained in:
falken10vdl
2025-07-04 12:35:17 +02:00
committed by GitHub
parent e52af2baad
commit f75045f0c5
5 changed files with 36 additions and 1 deletions
@@ -63,6 +63,7 @@ classes = (
operator.HighlightProductCostItem,
operator.ImportCostScheduleCsv,
operator.RefreshCostScheduleCsv,
operator.RemoveCostScheduleCsvLink,
operator.LoadCostItemElementQuantities,
operator.LoadCostItemQuantities,
operator.ShowAssignedCostRate,
@@ -615,6 +615,34 @@ class RefreshCostScheduleCsv(bpy.types.Operator, tool.Ifc.Operator):
return {"FINISHED"}
class RemoveCostScheduleCsvLink(bpy.types.Operator, tool.Ifc.Operator):
bl_idname = "bim.remove_cost_schedule_csv_link"
bl_label = "Remove CSV Link"
bl_description = "Remove the link to the CSV file and delete the related document reference"
bl_options = {"REGISTER", "UNDO"}
@classmethod
def poll(cls, context):
props = tool.Cost.get_cost_props()
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.remove_cost_schedule_csv_link(tool.Cost)
return {"FINISHED"}
def invoke(self, context, event):
return context.window_manager.invoke_confirm(self, event)
class AddCostColumn(bpy.types.Operator):
bl_idname = "bim.add_cost_column"
bl_label = "Add Cost Column"
+1
View File
@@ -84,6 +84,7 @@ class BIM_PT_cost_schedules(Panel):
if file_path:
row_1.label(text=file_path)
row_1.operator("bim.refresh_cost_schedule_csv", icon="FILE_REFRESH", text="")
row_1.operator("bim.remove_cost_schedule_csv_link", icon="X", text="")
else:
row_1.label(text="No CSV file found")
row_1.operator("bim.import_cost_schedule_csv", icon="IMPORT", text="")
+6
View File
@@ -361,6 +361,12 @@ def refresh_cost_schedule_csv(cost: type[tool.Cost]) -> Optional[str]:
cost.load_cost_schedule_tree()
def remove_cost_schedule_csv_link(cost: type[tool.Cost]) -> None:
cost_schedule = cost.get_active_cost_schedule()
if cost_schedule:
cost.remove_csv_filepath(cost_schedule)
def add_cost_column(cost: type[tool.Cost], name: str) -> None:
cost.add_cost_column(name)
-1
View File
@@ -697,7 +697,6 @@ class Cost(bonsai.core.tool.Cost):
def refresh_cost_schedule_csv(cls):
"""Refresh cost schedule from CSV file stored in document references."""
from ifc5d.csv2ifc import Csv2Ifc
import os
props = cls.get_cost_props()
cost_schedule_id = props.active_cost_schedule_id