repro:
- Run Blender 4.2.0
- File -> New -> General
- Scripting Workspace
- Template -> Simple Operator
replace main function with
def main(context):
bpy.ops.console.scrollback_append(text="hello world", type="OUTPUT")
Blender generates a runtime error because object.
Python: Traceback (most recent call last):
File "/operator_simple.py", line 41, in <module>
File "./blender-4.2.0-linux-x64/4.2/scripts/modules/bpy/ops.py", line 109, in __call__
ret = _op_call(self.idname_py(), kw)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
RuntimeError: Error: Python: Traceback (most recent call last):
File "/operator_simple.py", line 18, in execute
File "/operator_simple.py", line 5, in main
File "./blender-4.2.0-linux-x64/4.2/scripts/modules/bpy/ops.py", line 109, in __call__
ret = _op_call(self.idname_py(), kw)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
RuntimeError: Operator bpy.ops.console.scrollback_append.poll() failed, context is incorrect
Location: ./blender-4.2.0-linux-x64/4.2/scripts/modules/bpy/ops.py:109
What context needs to be setup?
in blender 3.x i would specify an override for window, screen, area
override = {'window': window, 'screen': screen, 'area': area}
bpy.ops.console.scrollback_append(overide, text='hello world', type="OUTPUT")
but in blender4, i cannot seem to specify these, either as args (no accepted), kwargs (ignored), or bpy.context (refused mutation, read only). i suppose there are other, less accessible ways to change the window, screen, and area.
might be looking into a temporary change current window