diff --git a/src/blenderbim/blenderbim/bim/export_ifc.py b/src/blenderbim/blenderbim/bim/export_ifc.py index c16839a3ab..39bc82df35 100644 --- a/src/blenderbim/blenderbim/bim/export_ifc.py +++ b/src/blenderbim/blenderbim/bim/export_ifc.py @@ -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": diff --git a/src/blenderbim/test/bim/feature/project.feature b/src/blenderbim/test/bim/feature/project.feature index 4cbefdb77d..189d244bd1 100644 --- a/src/blenderbim/test/bim/feature/project.feature +++ b/src/blenderbim/test/bim/feature/project.feature @@ -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