0
$\begingroup$

I've been trying to use the 'bpy.ops.outliner.select_walk' functionality which walks up and down the list of objects in the outliner with the arrow keys. I want to use this functionality while in the context of the 3D viewport, similar to what ZBrush and Maya do by default. By default in Blender, this functionality only works when hovering the mouse over the Outliner and pressing the up and down arrow keys.

Therefore, I'm trying to make a Python script to force the context to be 'Outliner', even when I'm in the 3D viewport.

After some research, I have found and tried to adapt some existing examples such as the 2 different approaches below, which both use 'bpy.context.temp_override()'. However, I can't get either of these code to work in the scenario of forcing Outliner context whilst in the 3d viewport context. I can only get it to work for it's original purpose of overriding the Blender text editor context with the 'VIEW_3D' context, and performing an operator such as adding primitives and overriding.

I have errors in the VS Code terminal like: ERROR (wm.operator): C:\Users\blender\git\blender-v360\blender.git\source\blender\windowmanager\intern\wm_event_system.cc:1551 wm_operator_invoke: invalid operator call 'OUTLINER_OT_select_walk'

def execute(self, context):

    area = [area for area in bpy.context.screen.areas if area.type == "OUTLINER"][0]

    with bpy.context.temp_override(area=area):
            bpy.ops.outliner.select_walk(direction='UP')

    return {'FINISHED'}


def execute(self, context):
    
    for window in context.window_manager.windows:
        for area in window.screen.areas:
            if area.type == 'OUTLINER':
                with context.temp_override(window=window, area=area):
                    bpy.ops.outliner.select_walk(direction='DOWN')
                break

    return {'FINISHED'}

Any help would be greatly appreciated, thanks.

$\endgroup$

0

You must log in to answer this question.

Browse other questions tagged .