mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-28 19:27:10 +00:00
IFCCSV can now be included as a library in your app!
This commit is contained in:
+48
-47
@@ -268,51 +268,52 @@ class IfcCsv():
|
|||||||
IfcAttributeExtractor.set_element_key(element, headers[i], value)
|
IfcAttributeExtractor.set_element_key(element, headers[i], value)
|
||||||
ifc_file.write(ifc)
|
ifc_file.write(ifc)
|
||||||
|
|
||||||
parser = argparse.ArgumentParser(
|
if __name__ == '__main__':
|
||||||
description='Exports IFC data to and from CSV')
|
parser = argparse.ArgumentParser(
|
||||||
parser.add_argument(
|
description='Exports IFC data to and from CSV')
|
||||||
'-i',
|
parser.add_argument(
|
||||||
'--ifc',
|
'-i',
|
||||||
type=str,
|
'--ifc',
|
||||||
required=True,
|
type=str,
|
||||||
help='The IFC file')
|
required=True,
|
||||||
parser.add_argument(
|
help='The IFC file')
|
||||||
'-c',
|
parser.add_argument(
|
||||||
'--csv',
|
'-c',
|
||||||
type=str,
|
'--csv',
|
||||||
default='data.csv',
|
type=str,
|
||||||
help='The CSV file to import from or export to')
|
default='data.csv',
|
||||||
parser.add_argument(
|
help='The CSV file to import from or export to')
|
||||||
'-q',
|
parser.add_argument(
|
||||||
'--query',
|
'-q',
|
||||||
type=str,
|
'--query',
|
||||||
default='',
|
type=str,
|
||||||
help='Specify a IFC query selector, such as ".IfcWall"')
|
default='',
|
||||||
parser.add_argument(
|
help='Specify a IFC query selector, such as ".IfcWall"')
|
||||||
'-a',
|
parser.add_argument(
|
||||||
'--arguments',
|
'-a',
|
||||||
nargs='+',
|
'--arguments',
|
||||||
help='Specify attributes that are part of the extract')
|
nargs='+',
|
||||||
parser.add_argument(
|
help='Specify attributes that are part of the extract')
|
||||||
'--export',
|
parser.add_argument(
|
||||||
action='store_true',
|
'--export',
|
||||||
help='Export from IFC to CSV')
|
action='store_true',
|
||||||
parser.add_argument(
|
help='Export from IFC to CSV')
|
||||||
'--import',
|
parser.add_argument(
|
||||||
action='store_true',
|
'--import',
|
||||||
help='Import from CSV to IFC')
|
action='store_true',
|
||||||
args = parser.parse_args()
|
help='Import from CSV to IFC')
|
||||||
|
args = parser.parse_args()
|
||||||
|
|
||||||
if args.export:
|
if args.export:
|
||||||
ifc_selector_parser = IfcSelectorParser()
|
ifc_selector_parser = IfcSelectorParser()
|
||||||
ifc_selector_parser.ifc = args.ifc
|
ifc_selector_parser.ifc = args.ifc
|
||||||
ifc_selector_parser.query = args.query
|
ifc_selector_parser.query = args.query
|
||||||
ifc_selector_parser.parse()
|
ifc_selector_parser.parse()
|
||||||
ifc_csv = IfcCsv()
|
ifc_csv = IfcCsv()
|
||||||
ifc_csv.output = args.csv
|
ifc_csv.output = args.csv
|
||||||
ifc_csv.attributes = args.arguments if args.arguments else []
|
ifc_csv.attributes = args.arguments if args.arguments else []
|
||||||
ifc_csv.export(ifc_selector_parser.results)
|
ifc_csv.export(ifc_selector_parser.results)
|
||||||
elif getattr(args, 'import'):
|
elif getattr(args, 'import'):
|
||||||
ifc_csv = IfcCsv()
|
ifc_csv = IfcCsv()
|
||||||
ifc_csv.output = args.csv
|
ifc_csv.output = args.csv
|
||||||
ifc_csv.Import(args.ifc)
|
ifc_csv.Import(args.ifc)
|
||||||
|
|||||||
Reference in New Issue
Block a user