Fix bug where sometimes migrating an IFC file schema version can explode in filesize

This commit is contained in:
Dion Moult
2021-04-28 16:53:38 +10:00
parent 357fcded71
commit 319b59a266
2 changed files with 4 additions and 4 deletions
+1 -1
View File
@@ -17,7 +17,7 @@ def execute(args, is_library=None):
patcher = recipe.Patcher(args["input"], ifc_file, logger, args["arguments"]) patcher = recipe.Patcher(args["input"], ifc_file, logger, args["arguments"])
print("# Patching ...") print("# Patching ...")
patcher.patch() patcher.patch()
ifc_file = patcher.file ifc_file = getattr(patcher, "file_patched", patcher.file)
if is_library is True: if is_library is True:
return ifc_file return ifc_file
print("# Writing patched file ...") print("# Writing patched file ...")
+3 -3
View File
@@ -10,9 +10,9 @@ class Patcher:
self.args = args self.args = args
def patch(self): def patch(self):
self.new = ifcopenshell.file(schema=self.args[0]) self.file_patched = ifcopenshell.file(schema=self.args[0])
migrator = ifcopenshell.util.schema.Migrator() migrator = ifcopenshell.util.schema.Migrator()
for element in self.file: for element in self.file:
migrator.migrate(element, self.file_patched)
print("Migrating", element) print("Migrating", element)
print("Successfully converted to", migrator.migrate(element, self.new)) print("Successfully converted to", migrator.migrate(element, self.file_patched))
self.file = self.new