Posebone : how do I script a "twisting" rotation over a posed bone ?

Hi,

I’m working on a script that needs to rotate a posed bone over its length, in the modeling window this is done easily by selecting the transform orientation to “normal” or “gimbal” and rotate away!
However, how do I add that kind of rotation in a script ?

I tried this:

rotq=mathutils.Quaternion()
rotq.w=radians(45) #let’s rotate 45 degrees
rotq.x=0
rotq.y=0
rotq.z=1#over the z-axis
pbone.rotation_mode=“QUATERNION”
pbone.rotation_quaternion+=rotq

Which was obviously wrong,
then I just thought to do this:

pbone.rotation_mode=“QUATERNION”
pbone.rotation_quaternion.w+=radians(45)

nope…

then this:
pbone.rotation_mode=“AXIS_ANGLE”
pbone.rotation_axis_angle[0]+=radians(45)

none of these work, obviously because I do not know what I’m doing…
Any of you know where I went wrong,
Appreciated much…

wzzl

Well, I think you are missing either “update()” of the armature, Window Redraw() and/or “inserting a key” in the respective IPO. Sorry that can’t tell you it is exactly in 2.5 but in 2.4x the latter goes like this:

    posebone.insertKey(ob,frm,Object.Pose.ROT)

where ob is your armature object, frm is the frame number.

Regards,

Thnks for the reply Adibos, but I am not looking to animate the bone, but position and orienting it.
Maybe it’s better to not think of this as bones, but of Empties, my workflow needs to be like this:
-move empty to new position (easy)
-rotate_euler to align Z-axis with a vector (took some time to figure out euler rotations, but, done)
Now my problem is:
-rotate empty (over its own Z-axis) to align the X-axis to another vector…

??

I looks to me like rotating properly about an axis perpendicular to both global Z and local X of empty… Isnt it?