For posterity, here’s the python code I used to solve this problem. It basically allows me to have a custom keying set to animate different characters, assuming the bone names are the same (rather than having a different keying set for each character). Only location and rotation are keyed. The code would be fairly easy to customize: just change the names of the bones in the “bones_rotation” and “bones_location” sets to tell the script which bones to key for which properties.
class BUILTIN_KSI_AnimStickMan(bpy.types.KeyingSetInfo):
# this defines how the keying set will appear in the keyingset menu at the bottom of the 3-d window
bl_label = "AnimStickMan"
# Keyingset options
bl_options = {'INSERTKEY_XYZ_TO_RGB'}
# Sets that determine what properties (location and rotation) are keyframed for what bones
bones_rotation = {"UpperSpine", "Toe.r", "Toe.l", "Hand.r", "Hand.l", "LowerSpine", "FootIK.r", "FootIK.l"}
bones_location = {"LowerSpine", "FootIK.r", "FootIK.l", "ArmIK.l", "ArmIK.r", "PoleTargetArm.l", "PoleTargetArm.r", "HeadTarget", "KneePoleTarget.l", "KneePoleTarget.r"}
# this is the union of the two sets, used in the iterator function to iterate through each of the bones
defined_bones = bones_rotation | bones_location
# poll
def poll(ksi, context):
ob = context.active_object
if ob:
return ob.mode == 'POSE'
else:
return False
#iterator
def iterator(ksi, context, ks):
# get the active object from the context and store it in a convience variable
ob = context.active_object
# reality check to make sure the active object is an armature in pose mode
if ob and ob.mode == 'POSE':
# go through all of the defined bones and call the generate functionon them
for boneName in BUILTIN_KSI_AnimStickMan.defined_bones:
# make sure the bone is defined in the armature
if (boneName in ob.pose.bones):
ksi.generate(context, ks, ob.pose.bones[boneName])
# generate - adds the paths to the keyframed properties to the keying set
def generate(ksi, context, ks, bone):
# get id-block and path info
id_block, base_path, grouping = keyingsets_utils.get_transform_generators_base_info(bone)
# deal with the rotation keys
if (bone.name in BUILTIN_KSI_AnimStickMan.bones_rotation):
keyingsets_utils.RKS_GEN_rotation(ksi, context, ks, bone)
# deal with the location keys
if (bone.name in BUILTIN_KSI_AnimStickMan.bones_location):
keyingsets_utils.RKS_GEN_location(ksi, context, ks, bone)