Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Does this work for Blender 4.0? #153

Closed
AhmedSalih3d opened this issue Nov 14, 2023 · 8 comments
Closed

Does this work for Blender 4.0? #153

AhmedSalih3d opened this issue Nov 14, 2023 · 8 comments

Comments

@AhmedSalih3d
Copy link

Hello!

I tried to give this a shot for Blender 4.0, but unfortunately it does not seem to run out of the box.

Has anyone else managed to?

Kind regards

@JamesLedger
Copy link

JamesLedger commented Nov 14, 2023

Hi, I've got it working fine with Blender 4.1 alpha using v0.0.18.

It could be that your original script doesn't work with Blender anymore as version 4.0 introduced a bunch of breaking changes for the api.

What error are you getting?

@AhmedSalih3d
Copy link
Author

Hi!

Using the Blender 4.0 LTS version and having a script with just print("Hello") I see the following:

in run_script_action bpy.ops.dev.run_script(context, filepath=path) File "c:\Program Files\Blender Foundation\Blender 4.0\4.0\scripts\modules\bpy\ops.py", line 106, in __call__ C_exec, C_undo = _BPyOpsSubModOp._parse_args(args) File "c:\Program Files\Blender Foundation\Blender 4.0\4.0\scripts\modules\bpy\ops.py", line 60, in _parse_args raise ValueError("1-2 args execution context is supported") ValueError: 1-2 args execution context is supported

Did you see this one too?

It works fine with Blender 3.6, without that error

@roguesleipnir
Copy link

in run_script_action bpy.ops.dev.run_script(context, filepath=path) File "c:\Program Files\Blender Foundation\Blender 4.0\4.0\scripts\modules\bpy\ops.py", line 106, in __call__ C_exec, C_undo = _BPyOpsSubModOp._parse_args(args) File "c:\Program Files\Blender Foundation\Blender 4.0\4.0\scripts\modules\bpy\ops.py", line 60, in _parse_args raise ValueError("1-2 args execution context is supported") ValueError: 1-2 args execution context is supported

I'm also trying to get it to work with today's 4.0 release, I'm experiencing the same error.
Attaching 3.6 also still works.

@CGArtPython
Copy link
Collaborator

This issue is connected to a breaking change that was introduced in Blender's 4.0 Python API update

https://wiki.blender.org/wiki/Reference/Release_Notes/4.0/Python_API

Blender Operators (bpy.ops)
Remove the context override argument to bpy.ops in favor of context.temp_override(..) (ac263a9bce)

In .\pythonFiles\include\blender_vscode\operators\script_runner.py instead of this
bpy.ops.dev.run_script(context, filepath=path)

We need to use this

    with bpy.context.temp_override(**context):
        bpy.ops.dev.run_script(filepath=path)

I'll submit a PR soon.

CGArtPython added a commit to CGArtPython/blender_vscode that referenced this issue Nov 20, 2023
Issue summary:
When using the "Run Script" command, the user hits
`scripts\modules\bpy\ops.py", line 60, in _parse_args raise ValueError("1-2 args execution context is supported") ValueError: 1-2 args execution context is supported`

Issue cause:
This issue is connected to a breaking change that was introduced in Blender's 4.0 Python API update

https://wiki.blender.org/wiki/Reference/Release_Notes/4.0/Python_API
> Blender Operators (bpy.ops)
> Remove the context override argument to bpy.ops in favor of context.temp_override(..) ([ac263a9bce](https://projects.blender.org/blender/blender/commit/ac263a9bce53e190d07d679a058a230e91e722be))

For Blender 4.0 in `.\pythonFiles\include\blender_vscode\operators\script_runner.py` instead of this
`bpy.ops.dev.run_script(context, filepath=path)`

We need to use this
```
    with bpy.context.temp_override(**context):
        bpy.ops.dev.run_script(filepath=path)
```

Tested "Run Script" and Add-on Debugging under Blender 2.9 and Blender 4.0
JacquesLucke added a commit that referenced this issue Nov 21, 2023
Fixing "Run Script" support for Blender 4.0 #153
@filibis
Copy link

filibis commented Nov 23, 2023

Hi @CGArtPython , I'm still having problem when starting Blender 4.0.1, will this commit change automatically apply to the extension? Or do I need to manually update something?
image

@Frutto-Hub
Copy link

Hi @CGArtPython , I'm still having problem when starting Blender 4.0.1, will this commit change automatically apply to the extension? Or do I need to manually update something? image

Hi, i am havaing the same issue. Seems like this issue is only fixed in this repo, but not in extension itself. You can manually add fix to script_runner.py file
not_updated_in_extension
Here is how it should be:
how to fix

@Frutto-Hub
Copy link

@JacquesLucke, please consider updating the extension itself

@JacquesLucke
Copy link
Owner

The updated extension is now live.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants