mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-09 09:21:46 +00:00
Merge pull request #3279 from nelsonhp3/v0.7.0
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"
|
||||
cost_schedule: bpy.props.IntProperty()
|
||||
format: bpy.props.EnumProperty("Format", items=(("CSV", "CSV", ""), ("XLSX", "XLSX", ""), ("ODS", "ODS", "")))
|
||||
filepath: bpy.props.StringProperty(subtype="FILE_PATH")
|
||||
|
||||
def execute(self, context):
|
||||
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):
|
||||
self.report({"ERROR"}, r)
|
||||
return {"FINISHED"}
|
||||
|
||||
def invoke(self, context, event):
|
||||
wm = context.window_manager
|
||||
return wm.invoke_props_dialog(self)
|
||||
wm.fileselect_add(self)
|
||||
return {"RUNNING_MODAL"}
|
||||
|
||||
def draw(self, context):
|
||||
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)
|
||||
|
||||
|
||||
def export_cost_schedules(cost, format, cost_schedule=None):
|
||||
def export_cost_schedules(cost, filepath, format, cost_schedule=None):
|
||||
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):
|
||||
|
||||
@@ -165,7 +165,7 @@ class Cost:
|
||||
def expand_cost_item_rate(cls, cost_item): pass
|
||||
def expand_cost_item(cls, cost_item): 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 get_active_cost_item(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
|
||||
|
||||
@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 os
|
||||
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):
|
||||
os.makedirs(path)
|
||||
if format == "CSV":
|
||||
|
||||
Reference in New Issue
Block a user