# Temporaly set an Armature to Rest Position

i need to do some calculations which only work in Rest pose. So i tried to do:

pose_position = arm.data.pose_position
arm.data.pose_position='REST'

# Do some calculations on the mesh objects bound to the armature

arm.data.pose_position=pose_position


But this simple idea does not work.

However, when i select Rest Position from the Blender User Interface before i call my script, then the script creates correct results. So the question is what does pressing the Rest Position Button in addition and how can i do that from Python as well?

• This may be something to do with needing a scene update before being able to access updated locations. See stackoverflow.com/questions/13840418/… – Ray Mairlot Jan 31 '15 at 16:58
• What is "arm" refering/pointing to? – Einar Jan 31 '15 at 18:15
• @Ray Mairlot: scene update does not help here (i tried that) – Gaia Clary Feb 5 '15 at 11:58
• @Naioai Studios: arm is the Armature object to which the meshes are bound which are used in the "some calculations" part. – Gaia Clary Feb 5 '15 at 12:00

## 1 Answer

You don't need to switch pose_position, because tail, head, matrix and so on are not affected by keyframed poses if you access the Armature data (Object.data.bones[#]).

If you access the pose data however (Object.pose.bones[#]), the properties will change based on the current frame.

• But i am not calculating anything on the armature. I am calculating data on the meshes which are bound to the armature (i.e. i generate Shape keys). – Gaia Clary Feb 2 '15 at 20:16
• So you are after the unaltered, undeformed mesh data? Or the meshes with everything applied except armature deformation? How is the mesh bound to the armature, using vertex weights? – CodeManX Feb 3 '15 at 1:16
• yes, i need to get the mesh in rest pose and yes it uses vertex weighting. – Gaia Clary Feb 3 '15 at 20:56
• The mesh data is not changed in any way by a deforming armature. There's no need to change it to the rest position. Select the armature and go to edit mode to see how the data is stored - there is no deformation and no pose. The pose data is stored elsewhere, and the mesh deformation is calculated on-the-fly. To get the deformed mesh, you need to apply the modifier, e.g. via Object.to_mesh(scene, True, 'PREVIEW'). – CodeManX Feb 4 '15 at 10:59
• yes, i indeed use Object.toMesh() as you propose. Actually my question was not about how to calculate something. It was more about why "setting the armature manually to Rest Pose, then calling my script" gives different results compared to "setting the armature to rest pose by script then calling my script". – Gaia Clary Feb 5 '15 at 11:54