mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-17 19:09:07 +00:00
Exporting cost schedules opens the folder directory
This commit is contained in:
@@ -634,7 +634,9 @@ class ExportCostSchedules(bpy.types.Operator):
|
||||
|
||||
def execute(self, context):
|
||||
cost_schedule = tool.Ifc.get().by_id(self.cost_schedule) if self.cost_schedule else None
|
||||
core.export_cost_schedules(tool.Cost, format=self.format, cost_schedule=cost_schedule)
|
||||
r = core.export_cost_schedules(tool.Cost, format=self.format, cost_schedule=cost_schedule)
|
||||
if isinstance(r, str):
|
||||
self.report({"ERROR"}, r)
|
||||
return {"FINISHED"}
|
||||
|
||||
def invoke(self, context, event):
|
||||
|
||||
@@ -237,7 +237,8 @@ def calculate_cost_item_resource_value(ifc, cost_item):
|
||||
|
||||
|
||||
def export_cost_schedules(cost, format, cost_schedule=None):
|
||||
cost.export_cost_schedules(format, cost_schedule)
|
||||
cost.play_sound()
|
||||
return cost.export_cost_schedules(format, cost_schedule)
|
||||
|
||||
|
||||
def clear_cost_item_assignments(ifc, cost, cost_item, related_object_type):
|
||||
|
||||
@@ -499,11 +499,14 @@ class Cost(blenderbim.core.tool.Cost):
|
||||
|
||||
@classmethod
|
||||
def export_cost_schedules(cls, format=None, cost_schedule=None):
|
||||
path = os.path.join(bpy.context.scene.BIMProperties.data_dir, "build", "cost_schedules")
|
||||
import subprocess
|
||||
import os
|
||||
import sys
|
||||
path = os.path.join(bpy.context.scene.BIMProperties.data_dir, "cost_schedules")
|
||||
if not os.path.exists(path):
|
||||
os.makedirs(path)
|
||||
if format == "CSV":
|
||||
from ifc5d.ifc5Dspreadsheet import Ifc5DCsvWriter
|
||||
if not os.path.exists(path):
|
||||
os.makedirs(path)
|
||||
writer = Ifc5DCsvWriter(file=tool.Ifc.get(), output=path, cost_schedule=cost_schedule)
|
||||
writer.write()
|
||||
elif format == "ODS":
|
||||
@@ -516,6 +519,16 @@ class Cost(blenderbim.core.tool.Cost):
|
||||
|
||||
writer = Ifc5DXlsxWriter(file=tool.Ifc.get(), output=path, cost_schedule=cost_schedule )
|
||||
writer.write()
|
||||
try:
|
||||
if path:
|
||||
if sys.platform == "win32":
|
||||
os.startfile(path)
|
||||
elif sys.platform == "darwin":
|
||||
subprocess.call(["open", path])
|
||||
elif sys.platform == "linux":
|
||||
subprocess.call(["xdg-open", path])
|
||||
except:
|
||||
return 'Could not open file location'
|
||||
|
||||
@classmethod
|
||||
def get_units(cls):
|
||||
@@ -659,4 +672,4 @@ class Cost(blenderbim.core.tool.Cost):
|
||||
|
||||
@classmethod
|
||||
def has_schedules(cls):
|
||||
return bool(tool.Ifc.get().by_type("IfcCostSchedule"))
|
||||
return bool(tool.Ifc.get().by_type("IfcCostSchedule"))
|
||||
|
||||
Reference in New Issue
Block a user