I am writing a custom exporter and need to determine which material animations go with specific armature animations. For example, my armature might have an action for throwing a punch, and the face material for the mesh attached to the armature might have an action for a concentrated expression (created via nodes). During the export, I need to be able to tell that these animations "go together." Is there a way to merge them into a single action in Blender? Or another way of associating the two together? Since there may be multiple such pairings I cannot rely on whatever the active action is for each.
Here's a quick draft of Marty Fouts' proposed solution:
import bpy arma = bpy.context.object assert arma.type == 'ARMATURE' and arma.animation_data is not None \ and len(arma.children) > 0 and arma.children.type == 'MESH' mesh = arma.children for track1 in arma.animation_data.nla_tracks: if len(track1.strips) == 0: continue strip1 = track1.strips for slot in mesh.material_slots: nodes = slot.material.node_tree if nodes.animation_data is None: continue for track2 in nodes.animation_data.nla_tracks: if len(track2.strips) == 0: continue strip2 = track2.strips if strip1.name == strip2.name: assert strip1.type == 'META' and strip2.type == 'META' arma_anim_name = strip1.strips.name mat_anim_name = strip2.strips.name arma_act = bpy.data.actions[arma_anim_name] mat_act = bpy.data.actions[mat_anim_name] # export actions...
A bunch of ugly
asserts that would be better dealt with gracefully, but it captures the idea.