Sub topic 18
Keyframing and Baking Constrained Animation
This chapter assumes you can create an armature, switch to Pose Mode, and set basic keyframes. You should also understand that a constraint changes a bone's final evaluated pose after its keyed transforms are applied.
Keyframe the Controls, Not the Solved Bones
With an IK rig, animate the IK target and pole target. The IK constraint then solves the arm chain on every frame. Keyframing the target keeps the setup editable because you can move the target, change the pole angle, or adjust the chain later.
Select a control bone in Pose Mode, change its location or rotation, and press I. Choose the appropriate keying option, such as Location, Rotation, or LocRot. Key the pole control when you need to change the elbow direction.
A constrained bone can also receive keyframes, but those keys may fight the constraint. If the constraint has full influence, the constraint usually determines the final result. Use keyed constraint influence when you want to blend or disable the constraint over time.
import bpy
rig = bpy.data.objects["ArmRig"]
bpy.context.view_layer.objects.active = rig
rig.select_set(True)
hand_ik = rig.pose.bones["hand_ik"]
hand_ik.location = (2.2, 0.4, 0.0)
hand_ik.keyframe_insert(data_path="location", frame=1)
bpy.context.scene.frame_set(20)
hand_ik.location = (2.0, 0.8, 0.2)
hand_ik.keyframe_insert(data_path="location", frame=20)Why Bake an Animation?
Baking samples the evaluated pose at many frames and writes those results as ordinary keyframes. This is useful when exporting to a format that does not support Blender constraints, handing animation to another application, or freezing a complex rig before cleanup.
The bake range and step control the result. A step of 1 creates a key on every frame and preserves fast changes more reliably. Larger steps create fewer keys but can miss sharp motion.
Bake Visual Results
Use visual keying so Blender records the pose after constraints have been evaluated. Without it, Blender may record the controls' raw transforms rather than the visible arm position.
import bpy
rig = bpy.data.objects["ArmRig"]
bpy.ops.object.mode_set(mode="POSE")
bpy.context.view_layer.objects.active = rig
rig.select_set(True)
bpy.ops.nla.bake(
frame_start=1,
frame_end=120,
step=1,
only_selected=False,
visual_keying=True,
clear_constraints=False,
use_current_action=True,
bake_types={"POSE"},
)Keep the constraints while checking the baked action. After confirming the result, you can remove constraints manually or bake with clear_constraints=True. Save a backup first because clearing constraints changes the rig.
Exercise
Why should an IK animator usually key the target control instead of the constrained forearm?
Show answer
The target defines the desired hand position, while the IK solver computes the forearm and upper-arm rotations. Keying the target preserves the rig's editable behavior.