The quaternion rotations on this bone (Bip01 Non Accum) is messed up, and they need to be flipped. All the keyframes from 532 to 592 need to have their quat rotations flipped and inserted as new keyframes. I just want to find a way to script it so I can just box select all the affected keyframes and flip their rotations, then insert them as new keyframes overwriting their old ones. At the bottom is a script that does the operator combo, but it only works on the active keyframe(In the picture, it would be frame 532), meaning I still need to move to the next affected keyframe and active the script on it's keyframe and so on. How would I change it to apply to multiple selected keyframes in one go?
import bpy
def flip_selected_keyframes():
bpy.ops.pose.quaternions_flip()
bpy.ops.anim.keyframe_insert()
flip_selected_keyframes()


