0
$\begingroup$

I need to find the previous f-curve keyframe a particular pose bone, to test if any of the transform values have changed. In fact my goal is iterating through all pose bones so I can keyframe_insert() new values where needed/changed, and possibly keyframe on a previous marker.

It's possible that some bone channel group names have been changed (e.g., instead of 7 location and rotation channels groups by bone name, there may be re-groupings like 'footIK.L.rotations' and 'footIK.L.locations', or some arbitrary re-grouping by a user like 'MyGroup'. So I can't reliably get to the groups (previous keys) with the bone name, nor pose bone via the group name.

bpy.data.objects['metarig.001'].pose.bones["footIK.R"] may be in group o.animation_data.action.groups['footIK.R.rot']

in which case a reference like o.animation_data.action.groups[ o.pose.bones['footIK.R'] ].channels[0] would throw an exception.

Is there a way to the o.animation_data.action.group via the o.pose.bone or visa versa?

$\endgroup$

1 Answer 1

0
$\begingroup$

I guess the following (mess) seems to work, or would there be other problems?

a_group.channels[0].data_path gives a string value like: 'pose.bones["thigh.R"].rotation_quaternion'

for ag in o.animation_data.action.groups:
      pbName = ag.channels[0].data_path.split('"')[1] # bone name
      pb = o.pose.bones[ pbName ] 

I was hoping for salvation, but I'll take a kludge.

$\endgroup$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .