4

Is there a way to test if an object in Blender has shape-keys or not?

A bou
  • 70
  • 1
  • 7

1 Answers1

5

Access shape key data via the object.data.shape_keys object, and the actual shape key blocks through object.data.shape_keys.key_blocks collection:

import bpy
# Reference active object
o = bpy.context.object

# Check if object has any shape keys at all (will be None if not)
if o.data.shape_keys:
    num_of_SK_blocks = len( o.data.shape_keys.key_blocks )
    print( "Number of shape keys: ", num_of_SK_blocks )
TLousky
  • 16,043
  • 1
  • 40
  • 72