# calculate roll

good afternoon.

does somebody could point me in the right direction to achieve copy the roll without using the bpy.ops options?? i have surfed the blender code in source/blender/editors/armature/editarmature_retarget, but it’s difficult to understand it??

thanks

From the console with rig object selected.

``````
&gt;&gt;&gt; C.object.data.edit_bones['RightLeg'].roll
0.0

``````

you need to be in edit mode.

maybe i had to explain better my problem. Imagine i have 2 bones in separate armatures, and with different rotations. i can copy the head and tail in order to get the same y axis, but i need to convert the roll from one to the other one. i’d like to understand the maths inside blender C code. i have been testing some aproximations playing with matrices, but finally i don’t get the correct result. i have been reading the C code, and it’s done with quaternions (operator calculate_roll). but i want to do it in python without using operators.

Search for mat3_to_vec_roll and vec_roll_to_mat3 in the C code.

``````def getRoll(bone):
mat = bone.matrix_local.to_3x3()
quat = mat.to_quaternion()
if abs(quat.w) &lt; 1e-4:
roll = pi
else:
roll = 2*atan(quat.y/quat.w)
return roll
``````

really grateful for the answers. i think this afternoon i’d have time to make some test. i post my results here.

thanks again