I'm trying to create a Python program by which a user could look at randomly generated poses of 3D model and choose if it to be saved in Pose Library until certain number of poses will be added. This is mentioned part of my code at the moment:

scene = bpy.context.scene
fp = os.path.join(bpy.path.abspath("//"), 'Poses') 
scene.render.image_settings.file_format = 'PNG'

num_poses = 0

while num_poses < 10:
    # Randomly generate pose
    # Missing as not important

    # Saving image of current pose to file so user can see it
    scene.render.filepath = os.path.join(fp, 'New Pose')

    # User chooses if it wants to save pose to Pose Library
    answer = input('Do you want to save this pose(y,n)? ')

    if answer == 'y':
        num_poses += 1 

The problem is that only the last pose is saved. If I understand correctly it should have something to do with frame number but when I tried to use

bpy.ops.poselib.pose_add(frame = 1+num_poses, name=str(num_poses))

only part of armature was changing when saved pose was selected.

I would be very thankful if somebody could help me or at least point me in the right direction.


1 Answer 1


I find a solution. If somebody else would want to do that, here's the code:


Before adding new poses, Blender requires that you select and deselect pose. Otherwise not whole armature is saved.


You must log in to answer this question.

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