Python exporter set armature to rest pose while exporting meshes I am exporting meshes attached to bones. For each mesh I have transform matrix
that is used to position mesh relative to bone. 
This relative matrix is calculated using:

obj.parent.data.bones[obj.parent_bone].matrix_local.inverted() * obj.matrix_local


When I export with armature in
rest position I get correct results. 



If I switch to pose position in blender and export, I get wrong results



I think that problem is obj.matrix_local which is based on current bone position.
How can I force rest position, or use other method to calculate object's transform
relative to bone.

armature.data.pose_position = 'REST' doesn't work from script, but looks like
it works from console.
I got armature.data.pose_position change to work
After changing to REST I had to call context.scene.update() and it calculates positions in rest pose. I change it once to pose when exporting keyframes and it is working as well.