example python script to change pose in pose mode?

Hi all,

Is there a way to change the pose in pose mode using a python script? For example, translate a bone which has IK.


I have an old code that rotates a bone on given angles. The proc supposes that you armature has a name aName and your bone of interest is bName. It inserts a key in the respective IPOs at Curr_Frame. It is for 2.4x…

def RotateBone(aName,bName,ax,ay,az):
    ob = bpy.data.objects[aName]
    pose = ob.getPose()
    posebone = pose.bones[bName]
    quat = posebone.quat
    eu = Mathutils.Euler(quat.toEuler())
    if (ax!=None):
        eu[0] = ax
    if (ay!=None):
        eu[1] = ay
    if (az!=None):
        eu[2] = az
    q = eu.toQuat()
    posebone.quat = q