You can now import and export IFCCSV to the current file in memory without writing to disk

This commit is contained in:
Dion Moult
2021-03-22 16:19:29 +11:00
parent 92d28901ac
commit 7c61c7d200
3 changed files with 24 additions and 16 deletions
+4 -4
View File
@@ -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)