Mute all animation channels in the Action Editor via script?

I want to mute all these animation channels with a script:

enter image description here

I tried using bpy.ops.anim.channels_setting_enable(type='MUTE') but that fails with an error saying that the context is incorrect.

Is there a variable that I can access or how do I correctly set the context for the function above to work? Thanks!

This should be in the Python API forum, not Blender Development.

You need to override the context with the correct area. That particular operator is expecting it to be fired from a DOPESHEET_EDITOR area type.

import bpy

def get_dopesheet_area():
    override_area = None
    for screen in bpy.context.workspace.screens:
        for area in screen.areas:
            if area.type == "DOPESHEET_EDITOR":
                return area
    return None

override = bpy.context.copy()
override["area"] = get_dopesheet_area()

if override["area"] is not None:
    bpy.ops.anim.channels_setting_enable(override, type='MUTE')

Ah you are right, I didn’t see that forum. The description of this one sounded like it belonged here.

Thanks a lot for the solution, it works but unfortunately it’s not practical in my case. Is there any way of achieving this without having to open the Action Editor?

Hi @Hotox,

Try posting your question here:

You don’t need the action editor open, just send it the correct workspace. Instead of context.workspace, just use[‘Animation’] instead.

Ah, that’s very useful information, thanks a ton!