Fix #1934. Fix bug with improper nesting of subfolders when exporting IfcZip.

This commit is contained in:
Dion Moult
2022-01-17 20:30:02 +11:00
parent 8b06aa9e0b
commit 2852f53afa
2 changed files with 12 additions and 4 deletions
+3 -3
View File
@@ -51,13 +51,13 @@ class IfcExporter:
if extension == "ifczip":
with tempfile.TemporaryDirectory() as unzipped_path:
filename, ext = os.path.splitext(os.path.basename(self.ifc_export_settings.output_file))
tmp_name = "{}.ifc".format(filename)
tmp_file = os.path.join(unzipped_path, tmp_name)
tmp_filename = f"{filename}.ifc"
tmp_file = os.path.join(unzipped_path, tmp_filename)
self.file.write(tmp_file)
with zipfile.ZipFile(
self.ifc_export_settings.output_file, mode="w", compression=zipfile.ZIP_DEFLATED, compresslevel=9
) as zf:
zf.write(tmp_file)
zf.write(tmp_file, arcname=tmp_filename)
elif extension == "ifc":
self.file.write(self.ifc_export_settings.output_file)
elif extension == "ifcjson":
@@ -62,6 +62,11 @@ Scenario: Load project
And the object "IfcWall/Wall" is in the collection "IfcBuildingStorey/Level 1"
And "scene.BIMProjectProperties.is_loading" is "False"
Scenario: Load project - IfcZip
Given an empty Blender session
And I press "bim.load_project(filepath='{cwd}/test/files/basic.ifczip')"
Then the object "IfcProject/My Project" is an "IfcProject"
Scenario: Load project - advanced mode
Given an empty Blender session
When I press "bim.load_project(filepath='{cwd}/test/files/basic.ifc', is_advanced=True)"
@@ -338,11 +343,14 @@ Scenario: Export IFC - with basic contents and saving as IfcJSON where import is
When I press "export_ifc.bim(filepath='{cwd}/test/files/export.ifcjson', should_save_as=True)"
Then "scene.BIMProperties.ifc_file" is "{cwd}/test/files/basic.ifc"
Scenario: Export IFC - with basic contents and saving as IfcZip where import is not supported
Scenario: Export IFC - with basic contents and round-tripping an IfcZip
Given an empty Blender session
And I press "bim.load_project(filepath='{cwd}/test/files/basic.ifc')"
When I press "export_ifc.bim(filepath='{cwd}/test/files/export.ifczip', should_save_as=True)"
Then "scene.BIMProperties.ifc_file" is "{cwd}/test/files/basic.ifc"
When an empty Blender session is started
And I press "bim.load_project(filepath='{cwd}/test/files/export.ifczip')"
Then the object "IfcProject/My Project" is an "IfcProject"
Scenario: Export IFC - with basic contents and saving as a relative path
Given an empty Blender session