mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-18 14:31:39 +00:00
You can now import and export IFCCSV to the current file in memory without writing to disk
This commit is contained in:
@@ -131,8 +131,7 @@ class IfcCsv:
|
||||
results.update([p.Name for p in element.Quantities])
|
||||
return ["{}.{}".format(pset_qto_name, n) for n in results]
|
||||
|
||||
def Import(self, ifc):
|
||||
ifc_file = ifcopenshell.open(ifc)
|
||||
def Import(self, ifc_file):
|
||||
with open(self.output, newline="", encoding="utf-8") as f:
|
||||
reader = csv.reader(f, delimiter=self.delimiter)
|
||||
headers = []
|
||||
@@ -149,7 +148,6 @@ class IfcCsv:
|
||||
if i == 0:
|
||||
continue # Skip GlobalId
|
||||
element = IfcAttributeSetter.set_element_key(ifc_file, element, headers[i], value)
|
||||
ifc_file.write(ifc)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
@@ -174,4 +172,6 @@ if __name__ == "__main__":
|
||||
elif getattr(args, "import"):
|
||||
ifc_csv = IfcCsv()
|
||||
ifc_csv.output = args.csv
|
||||
ifc_csv.Import(args.ifc)
|
||||
ifc_file = ifcopenshell.open(args.ifc)
|
||||
ifc_csv.Import(ifc_file)
|
||||
ifc_file.write(args.ifc)
|
||||
|
||||
Reference in New Issue
Block a user