mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-19 22:50:21 +00:00
implements fileselect to export_cost_schedules
This commit is contained in:
@@ -631,17 +631,19 @@ class ExportCostSchedules(bpy.types.Operator):
|
|||||||
bl_description = "Export a cost schedule to a CSV, XSLX OR ODS file"
|
bl_description = "Export a cost schedule to a CSV, XSLX OR ODS file"
|
||||||
cost_schedule: bpy.props.IntProperty()
|
cost_schedule: bpy.props.IntProperty()
|
||||||
format: bpy.props.EnumProperty("Format", items=(("CSV", "CSV", ""), ("XLSX", "XLSX", ""), ("ODS", "ODS", "")))
|
format: bpy.props.EnumProperty("Format", items=(("CSV", "CSV", ""), ("XLSX", "XLSX", ""), ("ODS", "ODS", "")))
|
||||||
|
filepath: bpy.props.StringProperty(subtype="FILE_PATH")
|
||||||
|
|
||||||
def execute(self, context):
|
def execute(self, context):
|
||||||
cost_schedule = tool.Ifc.get().by_id(self.cost_schedule) if self.cost_schedule else None
|
cost_schedule = tool.Ifc.get().by_id(self.cost_schedule) if self.cost_schedule else None
|
||||||
r = core.export_cost_schedules(tool.Cost, format=self.format, cost_schedule=cost_schedule)
|
r = core.export_cost_schedules(tool.Cost, filepath=self.filepath, format=self.format, cost_schedule=cost_schedule)
|
||||||
if isinstance(r, str):
|
if isinstance(r, str):
|
||||||
self.report({"ERROR"}, r)
|
self.report({"ERROR"}, r)
|
||||||
return {"FINISHED"}
|
return {"FINISHED"}
|
||||||
|
|
||||||
def invoke(self, context, event):
|
def invoke(self, context, event):
|
||||||
wm = context.window_manager
|
wm = context.window_manager
|
||||||
return wm.invoke_props_dialog(self)
|
wm.fileselect_add(self)
|
||||||
|
return {"RUNNING_MODAL"}
|
||||||
|
|
||||||
def draw(self, context):
|
def draw(self, context):
|
||||||
self.layout.label(text="Choose a format")
|
self.layout.label(text="Choose a format")
|
||||||
|
|||||||
@@ -236,9 +236,9 @@ def calculate_cost_item_resource_value(ifc, cost_item):
|
|||||||
ifc.run("cost.calculate_cost_item_resource_value", cost_item=cost_item)
|
ifc.run("cost.calculate_cost_item_resource_value", cost_item=cost_item)
|
||||||
|
|
||||||
|
|
||||||
def export_cost_schedules(cost, format, cost_schedule=None):
|
def export_cost_schedules(cost, filepath, format, cost_schedule=None):
|
||||||
cost.play_sound()
|
cost.play_sound()
|
||||||
return cost.export_cost_schedules(format, cost_schedule)
|
return cost.export_cost_schedules(filepath, format, cost_schedule)
|
||||||
|
|
||||||
|
|
||||||
def clear_cost_item_assignments(ifc, cost, cost_item, related_object_type):
|
def clear_cost_item_assignments(ifc, cost, cost_item, related_object_type):
|
||||||
|
|||||||
@@ -165,7 +165,7 @@ class Cost:
|
|||||||
def expand_cost_item_rate(cls, cost_item): pass
|
def expand_cost_item_rate(cls, cost_item): pass
|
||||||
def expand_cost_item(cls, cost_item): pass
|
def expand_cost_item(cls, cost_item): pass
|
||||||
def expand_cost_items(cls): pass
|
def expand_cost_items(cls): pass
|
||||||
def export_cost_schedules(cls, format, cost_schedule): pass
|
def export_cost_schedules(cls, filepath, format, cost_schedule): pass
|
||||||
def format_unit(cls, unit): pass
|
def format_unit(cls, unit): pass
|
||||||
def get_active_cost_item(cls): pass
|
def get_active_cost_item(cls): pass
|
||||||
def get_active_cost_schedule(cls): pass
|
def get_active_cost_schedule(cls): pass
|
||||||
|
|||||||
@@ -505,11 +505,15 @@ class Cost(blenderbim.core.tool.Cost):
|
|||||||
props.is_cost_update_enabled = True
|
props.is_cost_update_enabled = True
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def export_cost_schedules(cls, format=None, cost_schedule=None):
|
def export_cost_schedules(cls, filepath, format=None, cost_schedule=None):
|
||||||
import subprocess
|
import subprocess
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
path = os.path.join(bpy.context.scene.BIMProperties.data_dir, "cost_schedules")
|
if filepath:
|
||||||
|
path=filepath
|
||||||
|
else:
|
||||||
|
path = os.path.join(bpy.context.scene.BIMProperties.data_dir, "build", "cost_schedules")
|
||||||
|
|
||||||
if not os.path.exists(path):
|
if not os.path.exists(path):
|
||||||
os.makedirs(path)
|
os.makedirs(path)
|
||||||
if format == "CSV":
|
if format == "CSV":
|
||||||
|
|||||||
Reference in New Issue
Block a user