I need to fix up animation on a character mesh every time I resync a linked armature, because the related mesh shape_keys animation gets deleted. Manually I have to navigate to the mesh object, expand, find a track(?) called "Key.005", Add a Track and then find and assign my an action named "Key.005Action" to this NlaTrack (yes, really!).
I want to script around this ... predicament.
How do I script to find the key below the desired mesh name, select and add a track here?
Once I find and select the "Key.005" item/row I could then:
bpy.ops.nla.tracks_add(above_selected=False)
bpy.ops.nla.actionclip_add(action='Key.005Action')
Unfortunately this answer nor this doesn't get me there as nla_tracks for the main object are empty, as will be for the Key.005 sub-whatever.
I include a simple file with a cube with shape keys. How do I assign the KeyAction to "Key.001" with a python script? (but remember that the action on "Key" of "Cube" was deleted upon a resync!)
obj.data.shape_keys.animation_data.nla_tracks
. $\endgroup$obj.data.shape_keys.animation_data.nla_tracks[:]
returns[]
if there is no existing NlaTrack there, as happens when I resync the armature. So I need to find the "Key.005" row somehow, to thentracks_add()
. $\endgroup$obj.animation_data.nla_tracks.new()
will put a new track in the wrong place, and assigning the Key.005Action there will throw an error.Could not add action 'Key.005Action' as it cannot be used relative to ID-blocks of type 'OBGenesis8Male.Shape.001'
$\endgroup$obj.data.shape_keys.animation_data.nla_tracks
so you would doobj.data.shape_keys.animation_data.nla_tracks.new()
. $\endgroup$