Home Creators Posts Import Register Favorites Logout
haven't archived this post yet. have a subscription? use the importer!

Downloads

  • angle_test.blend

Missing 1 full-res photo, 1 file, as this post has not yet been imported.

Content

After days researching it, we've found a way to copy the angles from an object to bones.


Here is the code and the blend file is attached to this post

#This code was created to copy the angle between 2 points

#And transfer it to a Bone


import bpy,math
e1 = bpy.data.objects['Empty1'].location
e2 = bpy.data.objects['Empty2'].location
e3 = bpy.data.objects['Empty3'].location
#Euler Rotation Transfer
arm = bpy.context.scene.objects['Armature_Euler']
bone = arm.pose.bones['Bone']
rot_euler = e1.rotation_difference(e2-e1).to_euler()
bone.rotation_euler = rot_euler
print("X: %.2f, Y: %.2f, Z: %.2f" % tuple(math.degrees(a) for a in rot_euler))
#Quaternion Rotation Transfer
arm = bpy.context.scene.objects['Armature_Quaternion']
bone = arm.pose.bones['Bone']
rot_quaternion = e3.rotation_difference(e2-e3)
bone.rotation_quaternion = rot_quaternion
print("W: %.2f, X: %.2f, Y: %.2f, Z: %.2f" % tuple(math.degrees(a) for a in rot_quaternion))

Files

Previews only

Blender python - Transfer Angles from objects to bones

Here is an example of code to copy the angle between 2 objects to bones using Euler and Quaternion. You can get more information and the blend file in: https://www.patreon.com/posts/53499758

Comments

No comments found for this post.