I've been messing around with this for a while and I can't seem to find the connection between fcurves and the specific shape key values they control.

I can use something like the following: bpy.data.actions['KeyAction'].fcurves[0].data_path to get:'key_blocks["sitFix"].value'

But how do I get the shape key list that "sitFix" is in? bpy.data.shape_keys['Key'].key_blocks["sitFix"] i.e. 'Key' in this instance

Searching by name doesn't look like it will work, as Blender allows different shape key blocks to use the same name within different shape key lists, so there's a 'sitFix' in both 'Key' and 'Key.001'

Ultimately, I'm trying to see which mesh is being affected by a particular fcurve, but here I've hit a break in the chain connecting them.


key_block names can be used for different shape key lists, which means same shape key name but different objects. Every object uses its own action, thus you need to use the action the object references (Object.data.shape_keys.animation_data.action). See:

# Cube

>>> bpy.data.objects['Cube'].data.shape_keys.animation_data.action.fcurves[0].data_path
'key_blocks["Key 1"].value'

>>> bpy.data.objects['Cube'].data.shape_keys.animation_data.action.fcurves[0].id_data

# Cube.001

>>> bpy.data.objects['Cube.001'].data.shape_keys.animation_data.action.fcurves[0].data_path
'key_blocks["Key 1"].value'

>>> bpy.data.objects['Cube.001'].data.shape_keys.animation_data.action.fcurves[0].id_data
| improve this answer | |
  • $\begingroup$ Ah, so you're saying that the two 'sitFix' in the the two shape key lists I mentioned in my original post are actually the same single shape key block. That's good to know. But for the rest of your answer, what about the situation where there exists a shape key action that is not the active shape key action of a mesh? It definitely seems possible to make multiple shape key actions and even use them in the NLA editor. Are these actions not actually associated with the mesh until they are either made the active action or used in the NLA editor? $\endgroup$ – Konstantin Dec 30 '13 at 15:15
  • $\begingroup$ No, they are not the same shape key block, they are two distinct shape key blocks from two different actions. They are incidentially called the same way, but there's no actual relation. Every object can reference single shape keys datablock, this datablock can contain multiple shape keys (as seen in the shape keys list) plus a single shape key action. Such an action can be used by multiple objects ("active shape key action"), but you can also create distinct actions. If you re-use a single one, the shape key names need to match (data_path). Shape key actions are available for all objects. $\endgroup$ – CodeManX Dec 31 '13 at 0:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.