0

This script works till 3.6, but not 4.0.

import bpy

for a in bpy.context.screen.areas: if a.type == 'DOPESHEET_EDITOR':

    #deselect the keyframes
    bpy.ops.action.select_all({"area" : a}, action="DESELECT")
    break

4.0 says "ValueError: 1-2 args execution context is supported" in bpy.ops.action.select_all

Mrfas
  • 47
  • 6

1 Answers1

6

From version 3.2, context overriding this way is deprecated and is no more available in 4.0. Have a look for instance here and this is also documented in Blender wiki here.

What you can do instead is the following:

import bpy

for a in bpy.context.screen.areas: if a.type == 'DOPESHEET_EDITOR':

    with bpy.context.temp_override(area=a):
        bpy.ops.action.select_all(action="DESELECT")

    break

The Python with block allows to define the life time of this temporary override (the override is finished after this block).

If you need something that is compatible with version older than 3.2, you can test Blender version using bpy.app.version.

lemon
  • 60,295
  • 3
  • 66
  • 136