# delete shapekey keyframes with python

I thought this would be straight forward, but I'm still struggling to learn the API. I need to delete keyframes for shape keys on the selected or active objects (either or really at this point) For whatever reason this doesn't seem to work for shape keys.

import bpy

context = bpy.context

for ob in context.selected_objects:

ob.animation_data_clear()


Anyone any pointers?

Object animations are at object level (like location).

Shape keys animations are as its own data level. Add the line below:

import bpy

context = bpy.context

for ob in context.selected_objects:
ob.animation_data_clear()
ob.data.shape_keys.animation_data_clear() # <<<<


• thank you! something to get used to, but makes sense. – danulrich Nov 19 '20 at 8:28