JacquesLucke / blender_vscode

Visual Studio Code extension for Blender development.
MIT License
540 stars 70 forks source link

Does this work for Blender 4.0? #153

Closed AhmedSalih3d closed 7 months ago

AhmedSalih3d commented 7 months ago

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 commented 7 months ago

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 commented 7 months ago

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 commented 7 months ago

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 commented 7 months ago

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.

filibis commented 7 months ago

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 commented 7 months ago

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 commented 7 months ago

@JacquesLucke, please consider updating the extension itself

JacquesLucke commented 7 months ago

The updated extension is now live.