All pastes #285569 Raw Edit

Something

public text v1 · immutable
#285569 ·published 2006-12-19 22:23 UTC
rendered paste body
import Blender
from Blender import *

boneName = 'Bone.001'
arm = Armature.Get('Armature')
theBone = arm.bones[boneName]
parentBone = theBone.parent
boneTail = theBone.tail['ARMATURESPACE']
boneHead = theBone.head['ARMATURESPACE']
parentBoneHead = parentBone.head['ARMATURESPACE']
theNormal = Mathutils.TriangleNormal(boneTail, boneHead, parentBoneHead)
theRoll = Mathutils.Vector(0, 0, 1)*theBone.matrix['BONESPACE']
theAngle = Mathutils.AngleBetweenVecs(theNormal, theRoll)
arm.makeEditable()
arm.bones[boneName].roll = theAngle
arm.update()
print theAngle