mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-13 10:57:49 +00:00
Exporting cost schedules opens the folder directory
This commit is contained in:
@@ -30,10 +30,10 @@ import ifcopenshell.util.date
|
||||
|
||||
class IfcDataGetter:
|
||||
@staticmethod
|
||||
def get_schedules(file):
|
||||
if not file:
|
||||
return None
|
||||
return file.by_type("IfcCostSchedule")
|
||||
def get_schedules(file, filter_by_schedule=None):
|
||||
return [
|
||||
schedule for schedule in file.by_type("IfcCostSchedule") if not filter_by_schedule or schedule == filter_by_schedule
|
||||
]
|
||||
|
||||
@staticmethod
|
||||
def canonicalise_time(time):
|
||||
@@ -221,10 +221,6 @@ class Ifc5Dwriter:
|
||||
self.used_names = []
|
||||
for i in range(26):
|
||||
self.column_indexes.append("ABCDEFGHIJKLMNOPQRSTUVWXYZ"[i % 26])
|
||||
if self.cost_schedule:
|
||||
for cost_schedule in self.cost_schedules:
|
||||
if cost_schedule.id() != self.cost_schedule.id():
|
||||
self.cost_schedules.remove(cost_schedule)
|
||||
for cost_schedule in self.cost_schedules:
|
||||
sheet_id = cost_schedule.id()
|
||||
self.sheet_data[sheet_id] = {}
|
||||
@@ -269,7 +265,7 @@ class Ifc5Dwriter:
|
||||
return "{}{}".format(self.column_indexes[attribute], self.row_count)
|
||||
|
||||
def write(self):
|
||||
self.cost_schedules = IfcDataGetter.get_schedules(self.file)
|
||||
self.cost_schedules = IfcDataGetter.get_schedules(self.file, self.cost_schedule)
|
||||
self.sheet_data = {}
|
||||
self.parse()
|
||||
|
||||
@@ -311,10 +307,14 @@ class Ifc5DOdsWriter(Ifc5Dwriter):
|
||||
ns1.addElement(Number(decimalplaces="2", minintegerdigits="1", grouping="true"))
|
||||
self.doc.styles.addElement(ns1)
|
||||
|
||||
file_name = ""
|
||||
for cost_schedule in self.cost_schedules:
|
||||
if file_name:
|
||||
file_name += "_" + cost_schedule.Name or ""
|
||||
else:
|
||||
file_name += cost_schedule.Name or ""
|
||||
self.write_table(cost_schedule)
|
||||
|
||||
self.doc.save(self.output, True)
|
||||
self.doc.save(os.path.join(self.output, file_name), True)
|
||||
|
||||
def write_table(self, cost_schedule):
|
||||
from odf.table import Table, TableRow, TableCell
|
||||
@@ -408,8 +408,14 @@ class Ifc5DXlsxWriter(Ifc5Dwriter):
|
||||
import xlsxwriter
|
||||
|
||||
super().write()
|
||||
|
||||
self.workbook = xlsxwriter.Workbook(self.output + ".xlsx")
|
||||
file_name = ""
|
||||
for cost_schedule in self.cost_schedules:
|
||||
if file_name:
|
||||
file_name += "_" + cost_schedule.Name or ""
|
||||
else:
|
||||
file_name += cost_schedule.Name or ""
|
||||
self.file_path = os.path.join(self.output, "{}.xlsx".format(file_name))
|
||||
self.workbook = xlsxwriter.Workbook(self.file_path)
|
||||
self.used_names = []
|
||||
for cost_schedule in self.cost_schedules:
|
||||
self.write_table(cost_schedule)
|
||||
|
||||
Reference in New Issue
Block a user