The Pose Library doesn't really have a Python API (this makes me miss the pose lib a lot, tbh)
You can work around it by getting a hold of the SpaceFileBrowser
space_data
. I see people looping through the screens/areas etc, trying to find it (with heuristics like "what is the largest area on screen" and stuff like that). I just run the operator from the asset browser itself to just go context.space_data
.
This type of space_data
has a couple of methods that will allow you to prepare for the apply_pose_asset
operator. The most important one is activate_asset_by_id
. Note that it doesn't take a string, but if you know the name of your action, you can pluck it from bpy.data.actions
and pass the id_data
prop.
Then you can call the operator and the pose will be applied.
Just be careful with which selected bones you might have, etc. as it might make it seem that it's not working when it is.
See here a minimalist example:
def execute(self, context):
data = context.space_data
data.deselect_all()
data.activate_asset_by_id(bpy.data.actions['zz_jawDrop'].id_data)
bpy.ops.poselib.apply_pose_asset(blend_factor=1)
return {'FINISHED'}
{id = bpy.data.armatures["Armature.00x"]}
as an override ? $\endgroup$bpy.data.actions
but even with that it doesn't work. $\endgroup$