1
$\begingroup$

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?

$\endgroup$
0
$\begingroup$

the scrip is active.

""""""""""""""""""""""""""""""""""""""""""""""""

for f in range(sce.frame_start, sce.frame_end+1):
    sce.frame_set(f)
    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"
                bpy.ops.object.mode_set(mode='POSE')
                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)   

                bpy.context.scene.update()
                pbone.keyframe_insert(data_path="rotation_euler" ,frame=keyFrame)
                context.user_preferences.edit.keyframe_new_interpolation_type = keyInterp
                bpy.ops.object.mode_set(mode='OBJECT')
                pbone.rotation_mode = lastMode
| improve this answer | |
$\endgroup$

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.