From e868186897824e2d95714ea361bc60625c8b2478 Mon Sep 17 00:00:00 2001 From: Dion Moult Date: Sat, 6 Nov 2021 21:41:31 +1100 Subject: [PATCH] Resolve #1749. You can now save as another IFC filename. --- src/blenderbim/blenderbim/bim/module/project/operator.py | 5 +++-- src/blenderbim/blenderbim/bim/module/project/ui.py | 2 ++ src/blenderbim/test/bim/feature/project.feature | 8 +++++++- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/blenderbim/blenderbim/bim/module/project/operator.py b/src/blenderbim/blenderbim/bim/module/project/operator.py index b6d66ab36e..516b70f15c 100644 --- a/src/blenderbim/blenderbim/bim/module/project/operator.py +++ b/src/blenderbim/blenderbim/bim/module/project/operator.py @@ -740,12 +740,13 @@ class ExportIFC(bpy.types.Operator): filepath: bpy.props.StringProperty(subtype="FILE_PATH") json_version: bpy.props.EnumProperty(items=[("4", "4", ""), ("5a", "5a", "")], name="IFC JSON Version") json_compact: bpy.props.BoolProperty(name="Export Compact IFCJSON", default=False) + should_save_as: bpy.props.BoolProperty(name="Should Save As", default=False) def invoke(self, context, event): if not IfcStore.get_file(): self.report({"ERROR"}, "No IFC project is available for export - create or import a project first.") return {"FINISHED"} - if context.scene.BIMProperties.ifc_file: + if context.scene.BIMProperties.ifc_file and not self.should_save_as: self.filepath = context.scene.BIMProperties.ifc_file return self.execute(context) if not self.filepath: @@ -789,7 +790,7 @@ class ExportIFC(bpy.types.Operator): if not scene.DocProperties.ifc_files: new = scene.DocProperties.ifc_files.add() new.name = output_file - if not scene.BIMProperties.ifc_file: + if not scene.BIMProperties.ifc_file or self.should_save_as: scene.BIMProperties.ifc_file = output_file if bpy.data.is_saved and bpy.data.is_dirty and bpy.data.filepath: bpy.ops.wm.save_mainfile(filepath=bpy.data.filepath) diff --git a/src/blenderbim/blenderbim/bim/module/project/ui.py b/src/blenderbim/blenderbim/bim/module/project/ui.py index 1c654fd09b..de3ba45f37 100644 --- a/src/blenderbim/blenderbim/bim/module/project/ui.py +++ b/src/blenderbim/blenderbim/bim/module/project/ui.py @@ -134,6 +134,8 @@ class BIM_PT_project(Panel): row = self.layout.row(align=True) row.prop(props, "ifc_file", text="") row.operator("bim.reload_ifc_file", icon="FILE_REFRESH", text="") + op = row.operator("export_ifc.bim", icon="FILE_TICK", text="") + op.should_save_as = True row.operator("bim.select_ifc_file", icon="FILE_FOLDER", text="") row = self.layout.row(align=True) diff --git a/src/blenderbim/test/bim/feature/project.feature b/src/blenderbim/test/bim/feature/project.feature index 94f0ef1fab..5cfa76f322 100644 --- a/src/blenderbim/test/bim/feature/project.feature +++ b/src/blenderbim/test/bim/feature/project.feature @@ -324,7 +324,13 @@ Scenario: Export IFC - with basic contents 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.ifc')" - Then nothing happens + Then "scene.BIMProperties.ifc_file" is "{cwd}/test/files/basic.ifc" + +Scenario: Export IFC - with basic contents and saving as another file + 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.ifc', should_save_as=True)" + Then "scene.BIMProperties.ifc_file" is "{cwd}/test/files/export.ifc" Scenario: Export IFC - with deleted objects synchronised Given an empty IFC project