Hello!
I’m trying to write a script that acts on only the F-Curves of selected bones. With my Armature selected, I can access the bones’ F-Curves like this, but how I can tell if the F-Curve’s associated bone is selected?
action = bpy.context.active_object.animation_data.action
fcurves = action.fcurves
I’m currently working with this code where I gather the names from selected_pose_bones
and the armature’s fcurves
and compare them, but it doesn’t seem very efficient to do two loops:
action = bpy.context.active_object.animation_data.action
sel_bone_names = list()
for pb in bpy.context.selected_pose_bones:
sel_bone_names.append(pb.bone.name)
for fcurve in action.fcurves:
tmp = fcurve.data_path.split("[", maxsplit=1)[1].split("]", maxsplit=1)
bone_name = tmp[0][1:-1]
if bone_name in sel_bone_names:
print(fcurve.data_path)
Thank you!