mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-09 17:31:45 +00:00
Fix #3414. The project wizard now doesn't load a fresh session by default. Note that File > Open still enforces a fresh session.
This commit is contained in:
@@ -582,34 +582,34 @@ class LoadProject(bpy.types.Operator, IFCFileSelector):
|
||||
@persistent
|
||||
def load_handler(*args):
|
||||
bpy.app.handlers.load_post.remove(load_handler)
|
||||
if tool.Blender.is_default_scene():
|
||||
for obj in bpy.data.objects:
|
||||
bpy.data.objects.remove(obj)
|
||||
self.finish_loading_project(context)
|
||||
|
||||
if self.should_start_fresh_session:
|
||||
# WARNING: wm.read_homefile clears context
|
||||
# which could lead to some operators to fail:
|
||||
# WARNING: wm.read_homefile clears context which could lead to some
|
||||
# operators to fail:
|
||||
# https://blender.stackexchange.com/a/282558/135166
|
||||
# So we continue using the load_post handler
|
||||
# thats triggered when context is already restored
|
||||
# So we continue using the load_post handler thats triggered when
|
||||
# context is already restored
|
||||
bpy.app.handlers.load_post.append(load_handler)
|
||||
bpy.ops.wm.read_homefile()
|
||||
return {"FINISHED"}
|
||||
else:
|
||||
return self.finish_loading_project(context)
|
||||
|
||||
|
||||
def finish_loading_project(self, context):
|
||||
if not self.is_existing_ifc_file():
|
||||
return {"FINISHED"}
|
||||
|
||||
if tool.Blender.is_default_scene():
|
||||
for obj in bpy.data.objects:
|
||||
bpy.data.objects.remove(obj)
|
||||
|
||||
context.scene.BIMProperties.ifc_file = self.get_filepath()
|
||||
context.scene.BIMProjectProperties.is_loading = True
|
||||
context.scene.BIMProjectProperties.total_elements = len(tool.Ifc.get().by_type("IfcElement"))
|
||||
if not self.is_advanced:
|
||||
bpy.ops.bim.load_project_elements()
|
||||
return {"FINISHED"}
|
||||
|
||||
return {"FINISHED"}
|
||||
|
||||
def invoke(self, context, event):
|
||||
context.window_manager.fileselect_add(self)
|
||||
@@ -987,7 +987,7 @@ class ExportIFC(bpy.types.Operator):
|
||||
if bpy.data.is_saved and bpy.data.is_dirty and bpy.data.filepath:
|
||||
bpy.ops.wm.save_mainfile(filepath=bpy.data.filepath)
|
||||
blenderbim.bim.handler.purge_module_data()
|
||||
self.report({"INFO"}, f"IFC Project \"{os.path.basename(output_file)}\" Saved")
|
||||
self.report({"INFO"}, f'IFC Project "{os.path.basename(output_file)}" Saved')
|
||||
|
||||
if bpy.data.is_saved:
|
||||
bpy.ops.wm.save_mainfile("INVOKE_DEFAULT")
|
||||
|
||||
@@ -209,7 +209,6 @@ class BIM_PT_project(Panel):
|
||||
row = self.layout.row()
|
||||
row.label(text="File Not Saved", icon="ERROR")
|
||||
|
||||
|
||||
def draw_create_project_ui(self, context):
|
||||
props = context.scene.BIMProperties
|
||||
pprops = context.scene.BIMProjectProperties
|
||||
@@ -226,7 +225,7 @@ class BIM_PT_project(Panel):
|
||||
|
||||
row = self.layout.row(align=True)
|
||||
row.operator("bim.create_project")
|
||||
row.operator("bim.load_project").should_start_fresh_session = True
|
||||
row.operator("bim.load_project").should_start_fresh_session = False
|
||||
|
||||
|
||||
class BIM_PT_project_library(Panel):
|
||||
|
||||
Reference in New Issue
Block a user