Script:
import bpy
import math
def test_fn2(pose_bone):
rig = pose_bone.id_data
mat = rig.matrix_world @ pose_bone.matrix
vec = mat.col[1].normalized()
angle = math.degrees(math.acos(vec[2]))
return angle
bpy.app.driver_namespace["test_fn2"] = test_fn2
Settings:
Turn on resisterregister in Text Editor. And Auto Run Python Scripts in User Preferences if you need.
Expression: test_fn2(bones["Bone"])/45
Additions:
Original script has two mistakes.
Transformation matrix for converting to world space is
object.matrix_world @ pose_bone.matrix
Vector myvec needs to be normalized.