Action Ipos with Python (Armatures/Bones)

HI there eversybody.
I am erarly new to Blender and Python so please forgive me for stupid questions.

What I am trying right now is kind of lipsyncing but with bones. OK let’s stqart from scratch. I designed with a mesh a lip. This lip has 8 bones so that if I move one bone it tears a bit of this lip. LAter I want to set these bones dynamically because I am getting some valus out of my system for mouth positions. So now a bone has a head position and a tail position as well as weight and roll value and so on…
My interesst are only on Location (loc), Head and Tail. Using Python and looking into the Blender Python API on blender.org you can use setHead, setTail and setLoc. Well my first question is what do the values say you get back from getLoc?? What do these numbers mean and where is zero position for them?. Then I try to place the Action Keys with setPose. But that isn’t working correctly.
Here is my code bevor I am trying to explain more. Maybe somebody knows a simple example??

import Blender
from Blender import *
from Blender.Armature import *
from Blender.Armature.Bone import *

armObj = Object.New("Armature")
armData = Armature.Get("Armature")
print armData

bn = armData.getBones()
print bn

bn[0].setHead(0.0,0.0,0.0)
bn[0].setTail(2.0,1.0,0.0)


bn[1].setHead(3.0,2.0,1.0)
bn[1].setTail(4.0,4.0,1.0)

armObj.link(armData)
scn = Blender.Scene.getCurrent()
scn.link(armObj)

armObj.makeDisplayList()
Blender.Window.RedrawAll()
 
bn[1].setPose([ROT,LOC,SIZE])  
 
context = scn.getRenderingContext()
context.currentFrame(2)

bn[1].setLoc([3,4,5])
 
bn[1].setPose([ROT,LOC,SIZE])

I hope somebody can help me??

Your script should work. Be careful though - setPose() does not support IK animation. Make sure you have IK turned off on your bones. When you create a ‘primative’ armature the last bone is usually IK’ed. Turn it off.

(humor me :slight_smile: )
To get rid of the IK you need to go into edit mode on the armature, press ‘A’ for select all and then see if there are any IK’s active. If there is turn it off and exit edit mode.

To see the animation you need to go to the Action Editor and right click on the armature you created. You should see an action with 2 keyframes in a channel with the name of the bone you set the pose for. If you go to the IPO Curve Editor and switch to ‘Action’ instead of ‘Object’ you should see the the corresponding IPO curve values for this bone across the frames.
(Actions are a little weird - they are object independant until selected)

Loc, size and quat are the location, size and rotation of the bone. I believe that the quat value contains the rotation per frame of the bone (but don’t quote me on that). The best way to get the pose animation info is to get an action from the armature object, get a bone channel from the action and parse the IPO curve.

http://www.patricia3d.com/jpgs/man20341.jpg

I think setpose is removed in the new version.
see my page for the same problem
http://blenderartists.org/forum/showthread.php?t=63887&highlight=setquat
kk rawal