What is the proper python code to switch from IK to FK and back?

Issue #1984 invalid
John Keyberg created an issue

The Info Editor gives me something like this:

bpy.context.object.pose.bones["f_ring.01_ik.R"]["FK_IK"] = 1

But if I try to run this, it only updates the UI to show “1“ on the slider in the N panel, but the bones don’t move and if you afterwards try to move the slider manually, the normal 0 to 1 range is broken and you can input whatever number in the slider.

So what is the proper code to actually switch from IK to FK and back? I ask because I’m trying to assign shortcuts for this operation.

Comments (3)

  1. Thomas Larsson repo owner

    This is an update problem. If you toggle in and out of pose mode, the finger moves. And the property is a float, not an integer, so it must be set to 1.0.

    bpy.context.object.pose.bones["f_ring.01_ik.R"]["FK_IK"] = 1.0
    bpy.ops.object.posemode_toggle()
    bpy.ops.object.posemode_toggle()
    

  2. Log in to comment