2
$\begingroup$

I have a script that imports a rigged .glb file and I'd like to apply one of the poses from my pose library to the armature.

If I do this manually, the API is:

bpy.data.workspaces["Scripting"].active_pose_asset_index = 3
bpy.ops.poselib.apply_pose_asset(blend_factor=1, flipped=False)

But I cannot find the equivalent to the first line for assigning the active_post_asset_index within a script.

$\endgroup$
1
  • $\begingroup$ Blender 3.4 Can someone give me the full code There are 10 figures in scene and 10 poses in pose libray Pls give me code to assign those poses to figures/armatures using python $\endgroup$
    – satya v
    Commented Feb 4, 2023 at 12:29

2 Answers 2

2
$\begingroup$

Figured it out! In case anyone else is having the same issue:

bpy.data.objects['Armature'].animation_data_create()
bpy.data.objects['Armature'].animation_data.action = bpy.data.actions[1] 

First line creates actions for your armature (poses are stored as actions). Second line sets a particular action/pose.

$\endgroup$
0
$\begingroup$

Sometimes the pose does not get updated immediately. It helps to toggle the object mode in the Blender. bpy.ops.object.posemode_toggle()

$\endgroup$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .