mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-21 10:23:41 +00:00
Fix ifc5d documentation
Documentation claimed that ODS/XLSX output was to a given filename, but the code actually writes files with generated names in a folder. (also create the folder if necessary for convenience)
This commit is contained in:
+2
-2
@@ -96,11 +96,11 @@ writer.write()
|
|||||||
### CLI app for converting IFC files to CSV, ODS or XLSX format.
|
### CLI app for converting IFC files to CSV, ODS or XLSX format.
|
||||||
|
|
||||||
Usage:
|
Usage:
|
||||||
python ifc5Dspreadsheet.py input_file output_file [-l log_file] [-f format_type]
|
python ifc5Dspreadsheet.py input_file output_dir [-l log_file] [-f format_type]
|
||||||
|
|
||||||
Arguments:
|
Arguments:
|
||||||
input_file (str): The path to the input IFC file to process.
|
input_file (str): The path to the input IFC file to process.
|
||||||
output_file (str): The output directory for CSV or filename for other formats.
|
output_dir (str): The output directory.
|
||||||
|
|
||||||
Options:
|
Options:
|
||||||
-l, --log log_file (str): The path to the file where errors should be logged. Default is process.log.
|
-l, --log log_file (str): The path to the file where errors should be logged. Default is process.log.
|
||||||
|
|||||||
@@ -319,8 +319,8 @@ class Ifc5Dwriter:
|
|||||||
cost_schedule: Optional[ifcopenshell.entity_instance] = None,
|
cost_schedule: Optional[ifcopenshell.entity_instance] = None,
|
||||||
):
|
):
|
||||||
"""
|
"""
|
||||||
:param file: IFC file to exprot cost schedules from.
|
:param file: IFC file to export cost schedules from.
|
||||||
:param output: Output directory for csv files.
|
:param output: Output directory.
|
||||||
:param cost_schedule: exported cost schedule. If not provided, will export all available schedules.
|
:param cost_schedule: exported cost schedule. If not provided, will export all available schedules.
|
||||||
"""
|
"""
|
||||||
self.output = output
|
self.output = output
|
||||||
@@ -404,6 +404,7 @@ class Ifc5DCsvWriter(Ifc5Dwriter):
|
|||||||
import csv
|
import csv
|
||||||
|
|
||||||
super().write()
|
super().write()
|
||||||
|
os.makedirs(self.output, exist_ok=True)
|
||||||
for sheet, data in self.sheet_data.items():
|
for sheet, data in self.sheet_data.items():
|
||||||
with open(
|
with open(
|
||||||
os.path.join(self.output, "{}.csv".format(data["Name"])), "w", newline="", encoding="utf-8"
|
os.path.join(self.output, "{}.csv".format(data["Name"])), "w", newline="", encoding="utf-8"
|
||||||
@@ -436,6 +437,7 @@ class Ifc5DOdsWriter(Ifc5Dwriter):
|
|||||||
ns1.addElement(Number(decimalplaces="2", minintegerdigits="1", grouping="true"))
|
ns1.addElement(Number(decimalplaces="2", minintegerdigits="1", grouping="true"))
|
||||||
self.doc.styles.addElement(ns1)
|
self.doc.styles.addElement(ns1)
|
||||||
|
|
||||||
|
os.makedirs(self.output, exist_ok=True)
|
||||||
file_name = ""
|
file_name = ""
|
||||||
for cost_schedule in self.cost_schedules:
|
for cost_schedule in self.cost_schedules:
|
||||||
if file_name:
|
if file_name:
|
||||||
@@ -537,6 +539,7 @@ class Ifc5DXlsxWriter(Ifc5Dwriter):
|
|||||||
import xlsxwriter
|
import xlsxwriter
|
||||||
|
|
||||||
super().write()
|
super().write()
|
||||||
|
os.makedirs(self.output, exist_ok=True)
|
||||||
file_name = ""
|
file_name = ""
|
||||||
for cost_schedule in self.cost_schedules:
|
for cost_schedule in self.cost_schedules:
|
||||||
if file_name:
|
if file_name:
|
||||||
@@ -683,7 +686,7 @@ class Ifc5DPdfWriter(Ifc5Dwriter):
|
|||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
parser = argparse.ArgumentParser()
|
parser = argparse.ArgumentParser()
|
||||||
parser.add_argument("input", type=str, help="Specify an IFC file to process")
|
parser.add_argument("input", type=str, help="Specify an IFC file to process")
|
||||||
parser.add_argument("output", help="The output directory for CSV or filename for other formats")
|
parser.add_argument("output", help="The output directory")
|
||||||
parser.add_argument("-l", "--log", type=str, help="Specify where errors should be logged", default="process.log")
|
parser.add_argument("-l", "--log", type=str, help="Specify where errors should be logged", default="process.log")
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
"-f", "--format", type=str, help="Choose which format to export in (CSV/ODS/XLSX)", default="CSV"
|
"-f", "--format", type=str, help="Choose which format to export in (CSV/ODS/XLSX)", default="CSV"
|
||||||
|
|||||||
Reference in New Issue
Block a user