From 297303063e3a866d2621c1541a4fe83b1758161d Mon Sep 17 00:00:00 2001 From: Andrej730 Date: Wed, 22 Mar 2023 16:58:13 +0500 Subject: [PATCH] Small changes in default names for saving ifc projects 1) changed first ifc saving handler from save_pre to save_post so that in the situation when you just created with .blend file and started ifc project on save dialog would suggest the same name for the .ifc file and for .blend file (previously it was always suggesting ".ifc" and you had to type it in manually). 2) suggested default ifc project named changed from `.blend.ifc` to `.ifc` for simplicity. PS save_pre didn't really work anyway - by the time "save ifc dialog" file was invoked and appeared .blend file was already saved anyway. --- src/blenderbim/blenderbim/bim/__init__.py | 4 ++-- src/blenderbim/blenderbim/bim/module/project/operator.py | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/blenderbim/blenderbim/bim/__init__.py b/src/blenderbim/blenderbim/bim/__init__.py index b5f76ee8d1..2140dcb0c7 100644 --- a/src/blenderbim/blenderbim/bim/__init__.py +++ b/src/blenderbim/blenderbim/bim/__init__.py @@ -152,7 +152,7 @@ def register(): bpy.app.handlers.redo_post.append(handler.redo_post) bpy.app.handlers.load_post.append(handler.setDefaultProperties) bpy.app.handlers.load_post.append(handler.loadIfcStore) - bpy.app.handlers.save_pre.append(handler.ensureIfcExported) + bpy.app.handlers.save_post.append(handler.ensureIfcExported) bpy.types.Scene.BIMProperties = bpy.props.PointerProperty(type=prop.BIMProperties) bpy.types.Object.BIMObjectProperties = bpy.props.PointerProperty(type=prop.BIMObjectProperties) bpy.types.Material.BIMObjectProperties = bpy.props.PointerProperty(type=prop.BIMObjectProperties) @@ -174,7 +174,7 @@ def unregister(): bpy.utils.unregister_class(cls) bpy.app.handlers.load_post.remove(handler.setDefaultProperties) bpy.app.handlers.load_post.remove(handler.loadIfcStore) - bpy.app.handlers.save_pre.remove(handler.ensureIfcExported) + bpy.app.handlers.save_post.remove(handler.ensureIfcExported) del bpy.types.Scene.BIMProperties del bpy.types.Object.BIMObjectProperties del bpy.types.Material.BIMObjectProperties diff --git a/src/blenderbim/blenderbim/bim/module/project/operator.py b/src/blenderbim/blenderbim/bim/module/project/operator.py index f5ce03b437..ed5761bf80 100644 --- a/src/blenderbim/blenderbim/bim/module/project/operator.py +++ b/src/blenderbim/blenderbim/bim/module/project/operator.py @@ -35,6 +35,7 @@ from blenderbim.bim.ifc import IfcStore from blenderbim.bim.ui import IFCFileSelector from blenderbim.bim import import_ifc from blenderbim.bim import export_ifc +from pathlib import Path class CreateProject(bpy.types.Operator): @@ -828,7 +829,7 @@ class ExportIFC(bpy.types.Operator): self.filepath = os.path.abspath(os.path.join(bpy.path.abspath("//"), self.filepath)) return self.execute(context) if not self.filepath: - self.filepath = bpy.path.ensure_ext(bpy.data.filepath, ".ifc") + self.filepath = Path(bpy.data.filepath).with_suffix(".ifc").__str__() WindowManager = context.window_manager WindowManager.fileselect_add(self) return {"RUNNING_MODAL"}