I have the following code which I use for expanding all collections in the outliner
def toggle_collection_collapse(state):
area = next(a for a in bpy.context.screen.areas if a.type == 'OUTLINER')
bpy.ops.outliner.show_hierarchy({'area': area}, 'INVOKE_DEFAULT')
for i in range(state):
bpy.ops.outliner.expanded_toggle({'area': area})
area.tag_redraw()
class Expand_All(bpy.types.Operator):
bl_label = "Expand All"
bl_idname = "my.expand_all"
def execute(self, context):
toggle_collection_collapse(1)
return {'FINISHED'}
This used to work on Blender 3.6.5 but now in 4.0.1 I get this error
Traceback (most recent call last):
File "/Users/user/models.blend/Text", line 218, in execute
File "/Users/user/models.blend/Text", line 195, in toggle_collection_collapse
File "/Applications/Blender.app/Contents/Resources/4.0/scripts/modules/bpy/ops.py", line 106, in __call__
C_exec, C_undo = _BPyOpsSubModOp._parse_args(args)
File "/Applications/Blender.app/Contents/Resources/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
Seems like the problem is when calling this line bpy.ops.outliner.show_hierarchy({'area': area}, 'INVOKE_DEFAULT')
How I can fix this?
bpy.ops.outliner.select_walk('INVOKE_DEFAULT')
causes a critical error in Blender and it closes. And so far unfortunately i have not found any information on how to work around this problem. $\endgroup$