I want to write a function using python to modify the rotation_euler a bone in a frame, the next bones in that frame and the next frame it will automatically update under this change. Can anyone give me ideas?


the scrip is active.


for f in range(sce.frame_start, sce.frame_end+1):
    if f == FrameNumber:
        keyFrame = context.scene.frame_current
        keyInterp = context.user_preferences.edit.keyframe_new_interpolation_type
        print('key interp: {}'.format(keyInterp))
        for pbone in ob.pose.bones:
            if pbone.name == BoneName:

                lastMode = pbone.rotation_mode
                pbone.rotation_mode = "XYZ"
                pbone.bone.select = True                    
                pbone[pbone.name].rotation_euler.x = math.radians(ValueX)
                pbone[pbone.name].rotation_euler.y = math.radians(ValueY)
                pbone[pbone.name].rotation_euler.z = math.radians(ValueZ)   

                pbone.keyframe_insert(data_path="rotation_euler" ,frame=keyFrame)
                context.user_preferences.edit.keyframe_new_interpolation_type = keyInterp
                pbone.rotation_mode = lastMode
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.