mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-26 18:21:59 +00:00
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:
@@ -63,6 +63,7 @@ classes = (
|
|||||||
operator.HighlightProductCostItem,
|
operator.HighlightProductCostItem,
|
||||||
operator.ImportCostScheduleCsv,
|
operator.ImportCostScheduleCsv,
|
||||||
operator.RefreshCostScheduleCsv,
|
operator.RefreshCostScheduleCsv,
|
||||||
|
operator.RemoveCostScheduleCsvLink,
|
||||||
operator.LoadCostItemElementQuantities,
|
operator.LoadCostItemElementQuantities,
|
||||||
operator.LoadCostItemQuantities,
|
operator.LoadCostItemQuantities,
|
||||||
operator.ShowAssignedCostRate,
|
operator.ShowAssignedCostRate,
|
||||||
|
|||||||
@@ -615,6 +615,34 @@ class RefreshCostScheduleCsv(bpy.types.Operator, tool.Ifc.Operator):
|
|||||||
return {"FINISHED"}
|
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):
|
class AddCostColumn(bpy.types.Operator):
|
||||||
bl_idname = "bim.add_cost_column"
|
bl_idname = "bim.add_cost_column"
|
||||||
bl_label = "Add Cost Column"
|
bl_label = "Add Cost Column"
|
||||||
|
|||||||
@@ -84,6 +84,7 @@ class BIM_PT_cost_schedules(Panel):
|
|||||||
if file_path:
|
if file_path:
|
||||||
row_1.label(text=file_path)
|
row_1.label(text=file_path)
|
||||||
row_1.operator("bim.refresh_cost_schedule_csv", icon="FILE_REFRESH", text="")
|
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:
|
else:
|
||||||
row_1.label(text="No CSV file found")
|
row_1.label(text="No CSV file found")
|
||||||
row_1.operator("bim.import_cost_schedule_csv", icon="IMPORT", text="")
|
row_1.operator("bim.import_cost_schedule_csv", icon="IMPORT", text="")
|
||||||
|
|||||||
@@ -361,6 +361,12 @@ def refresh_cost_schedule_csv(cost: type[tool.Cost]) -> Optional[str]:
|
|||||||
cost.load_cost_schedule_tree()
|
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:
|
def add_cost_column(cost: type[tool.Cost], name: str) -> None:
|
||||||
cost.add_cost_column(name)
|
cost.add_cost_column(name)
|
||||||
|
|
||||||
|
|||||||
@@ -697,7 +697,6 @@ class Cost(bonsai.core.tool.Cost):
|
|||||||
def refresh_cost_schedule_csv(cls):
|
def refresh_cost_schedule_csv(cls):
|
||||||
"""Refresh cost schedule from CSV file stored in document references."""
|
"""Refresh cost schedule from CSV file stored in document references."""
|
||||||
from ifc5d.csv2ifc import Csv2Ifc
|
from ifc5d.csv2ifc import Csv2Ifc
|
||||||
import os
|
|
||||||
|
|
||||||
props = cls.get_cost_props()
|
props = cls.get_cost_props()
|
||||||
cost_schedule_id = props.active_cost_schedule_id
|
cost_schedule_id = props.active_cost_schedule_id
|
||||||
|
|||||||
Reference in New Issue
Block a user