From 88af3eb1a6742e8b5504d9412e5a5ceae2658e60 Mon Sep 17 00:00:00 2001 From: Andrej730 Date: Mon, 3 Feb 2025 17:27:14 +0500 Subject: [PATCH] Explicitly enable Bonsai in the second Blender instance #6092 To cover cases when Bonsai was enabled in current Blender sesssion and user prefs are not saved. --- src/bonsai/bonsai/bim/module/project/operator.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/bonsai/bonsai/bim/module/project/operator.py b/src/bonsai/bonsai/bim/module/project/operator.py index 5c22da6d8c..14d86b5b2e 100644 --- a/src/bonsai/bonsai/bim/module/project/operator.py +++ b/src/bonsai/bonsai/bim/module/project/operator.py @@ -1282,7 +1282,20 @@ except Exception as e: t = time.time() with tempfile.NamedTemporaryFile(mode="w", suffix=".py", delete=False) as temp_file: temp_file.write(code) - run = subprocess.run([bpy.app.binary_path, "-b", "--python", temp_file.name, "--python-exit-code", "1"]) + run = subprocess.run( + [ + bpy.app.binary_path, + "-b", + # Explicitly ask to enable Bonsai for this Blender instance + # as Bonsai may be just enabled and user preferences are not saved. + "--addons", + tool.Blender.get_blender_addon_package_name(), + "--python", + temp_file.name, + "--python-exit-code", + "1", + ] + ) if run.returncode == 1: print("An error occurred while processing your IFC.") if not blend_filepath.exists() or blend_filepath.stat().st_mtime < t: