bim.load_project to refresh session on execute not invoke

if you accidentally opened file dialog or just changed your mind it shouldn't remove all objects from the current blender session
This commit is contained in:
Andrej730
2023-07-12 17:10:30 +05:00
parent 56adfc70b5
commit ef8f825012
@@ -578,6 +578,13 @@ class LoadProject(bpy.types.Operator, IFCFileSelector):
should_start_fresh_session: bpy.props.BoolProperty(name="Should Start Fresh Session", default=True) should_start_fresh_session: bpy.props.BoolProperty(name="Should Start Fresh Session", default=True)
def execute(self, context): def execute(self, context):
if self.should_start_fresh_session:
bpy.ops.wm.read_homefile()
if tool.Blender.is_default_scene():
for obj in bpy.data.objects:
bpy.data.objects.remove(obj)
if not self.is_existing_ifc_file(): if not self.is_existing_ifc_file():
return {"FINISHED"} return {"FINISHED"}
context.scene.BIMProperties.ifc_file = self.get_filepath() context.scene.BIMProperties.ifc_file = self.get_filepath()
@@ -588,13 +595,6 @@ class LoadProject(bpy.types.Operator, IFCFileSelector):
return {"FINISHED"} return {"FINISHED"}
def invoke(self, context, event): def invoke(self, context, event):
if self.should_start_fresh_session:
bpy.ops.wm.read_homefile()
if tool.Blender.is_default_scene():
for obj in bpy.data.objects:
bpy.data.objects.remove(obj)
context.window_manager.fileselect_add(self) context.window_manager.fileselect_add(self)
return {"RUNNING_MODAL"} return {"RUNNING_MODAL"}