Skip to content
This repository has been archived by the owner on Sep 20, 2024. It is now read-only.

Blender: Use the new API for override context #6145

Merged
merged 3 commits into from
Jan 23, 2024

Conversation

simonebarbieri
Copy link
Contributor

Changelog Description

Blender 4.0 disabled the old API to override context. This API updates the code to use the new API.

Additional info

This change is compatible with Blender versions up to 3.2. Previous versions are not compatible with this new API.

Testing notes:

In Blender 4.0:

  1. Test FBX and Alembic extractors.
  2. Test load audio.
  3. Test Review extraction.

@simonebarbieri simonebarbieri added type: bug Something isn't working sponsored Client endorsed or requested host: Blender target: AYON labels Jan 17, 2024
@simonebarbieri simonebarbieri self-assigned this Jan 17, 2024
@ynbot
Copy link
Contributor

ynbot commented Jan 17, 2024

@ynbot ynbot added the size/S Denotes a PR changes 100-499 lines, ignoring general files label Jan 17, 2024
@LiborBatek
Copy link
Member

Hmm, Im still getting error when publishing review

DEBUG: fps: 25.0
DEBUG: start: 1001, end: 1050
DEBUG: Outputting images to C:\Users\lbate\AppData\Local\Temp\pyblish_tmp_i2pnpyqw\vanguard_reviewMain
Traceback (most recent call last):
  File "C:\Users\lbate\AppData\Local\Ynput\AYON\addons\openpype_3.18.5-nightly.1\openpype\hosts\blender\api\capture.py", line 279, in _independent_window
    yield window
  File "C:\Users\lbate\AppData\Local\Ynput\AYON\addons\openpype_3.18.5-nightly.1\openpype\hosts\blender\api\capture.py", line 96, in capture
    bpy.ops.render.opengl(
  File "C:\Work\REPO_SW\DCC\BLENDER\4.0.2\WINDOWS\4.0\scripts\modules\bpy\ops.py", line 109, in __call__
    ret = _op_call(self.idname_py(), kw)
RuntimeError: Operator bpy.ops.render.opengl.poll() failed, context is incorrect

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\lbate\AppData\Local\Ynput\AYON\dependency_packages\ayon_2310271602_windows.zip\dependencies\pyblish\plugin.py", line 527, in __explicit_process
    runner(*args)
  File "C:\Users\lbate\AppData\Local\Ynput\AYON\addons\openpype_3.18.5-nightly.1\openpype\hosts\blender\plugins\publish\extract_playblast.py", line 84, in process
    path = capture(**preset)
  File "C:\Users\lbate\AppData\Local\Ynput\AYON\addons\openpype_3.18.5-nightly.1\openpype\hosts\blender\api\capture.py", line 85, in capture
    with _independent_window() as window:
  File "C:\Work\REPO_SW\DCC\BLENDER\4.0.2\WINDOWS\4.0\python\lib\contextlib.py", line 153, in __exit__
    self.gen.throw(typ, value, traceback)
  File "C:\Users\lbate\AppData\Local\Ynput\AYON\addons\openpype_3.18.5-nightly.1\openpype\hosts\blender\api\capture.py", line 281, in _independent_window
    with bpy.context.temp_override(**context):
TypeError: Area not found in screen

@LiborBatek
Copy link
Member

@simonebarbieri any commits yet? I think the issue is still present. thx

Copy link
Member

@LiborBatek LiborBatek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

UPDATED: my fault because I was not in correct branch due to Addons bundle being set to Staging mode and not Prod...

Still throwing error on me when publish review

DEBUG: fps: 25.0
DEBUG: start: 1001, end: 1050
DEBUG: Outputting images to C:\Users\lbate\AppData\Local\Temp\pyblish_tmp_99s78e5t\vanguard_reviewMain
Traceback (most recent call last):
  File "C:\Users\lbate\AppData\Local\Ynput\AYON\dependency_packages\ayon_2401161802_windows.zip\dependencies\pyblish\plugin.py", line 527, in __explicit_process
    runner(*args)
  File "C:\Users\lbate\AppData\Local\Ynput\AYON\addons\openpype_3.18.4\openpype\hosts\blender\plugins\publish\extract_playblast.py", line 84, in process
    path = capture(**preset)
  File "C:\Users\lbate\AppData\Local\Ynput\AYON\addons\openpype_3.18.4\openpype\hosts\blender\api\capture.py", line 85, in capture
    with _independent_window() as window:
  File "C:\Work\REPO_SW\DCC\BLENDER\4.0.2\WINDOWS\4.0\python\lib\contextlib.py", line 135, in __enter__
    return next(self.gen)
  File "C:\Users\lbate\AppData\Local\Ynput\AYON\addons\openpype_3.18.4\openpype\hosts\blender\api\capture.py", line 273, in _independent_window
    bpy.ops.wm.window_new(context)
  File "C:\Work\REPO_SW\DCC\BLENDER\4.0.2\WINDOWS\4.0\scripts\modules\bpy\ops.py", line 106, in __call__
    C_exec, C_undo = _BPyOpsSubModOp._parse_args(args)
  File "C:\Work\REPO_SW\DCC\BLENDER\4.0.2\WINDOWS\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

@LiborBatek LiborBatek self-requested a review January 23, 2024 13:26
Copy link
Member

@LiborBatek LiborBatek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did test all kinds of publishes in blender 4.02 and Ayon mode and all working fine...

Screenshot 2024-01-23 135146

@simonebarbieri simonebarbieri merged commit 10eb79b into develop Jan 23, 2024
7 checks passed
@simonebarbieri simonebarbieri deleted the bugfix/OP-7960-blender_4_override_context branch January 23, 2024 14:26
@ynbot ynbot added this to the next-patch milestone Jan 23, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
host: Blender size/S Denotes a PR changes 100-499 lines, ignoring general files sponsored Client endorsed or requested target: AYON type: bug Something isn't working
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

3 participants