diff --git a/CHANGELOG.md b/CHANGELOG.md index 8db89b0..4eb8727 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,9 @@ ## Unreleased +### Fixed +- Fixed "Run Script" support for Blender 4.0. + ## [0.0.18] - 2023-04-02 diff --git a/pythonFiles/include/blender_vscode/operators/script_runner.py b/pythonFiles/include/blender_vscode/operators/script_runner.py index a1d022d..5cc584c 100644 --- a/pythonFiles/include/blender_vscode/operators/script_runner.py +++ b/pythonFiles/include/blender_vscode/operators/script_runner.py @@ -21,7 +21,14 @@ def execute(self, context): def run_script_action(data): path = data["path"] context = prepare_script_context(path) - bpy.ops.dev.run_script(context, filepath=path) + + if bpy.app.version < (4, 0, 0): + bpy.ops.dev.run_script(context, filepath=path) + return + + with bpy.context.temp_override(**context): + bpy.ops.dev.run_script(filepath=path) + def prepare_script_context(filepath): with open(filepath) as fs: