Home Website Youtube GitHub

How to rotate the leg_R0_ik_ctrl?

Hi there,
I’m rigging a biped using the template guide.
The model I’m riggin has toes pointed slightly out, so there is a slight rotation on the ancle. It doesn’t seem to matter how I place the guide the orientation of the ik Ctrl once I build the rig is always pointing down global Z. How can I control the rotation of the leg IK ctrl once the rig is built?

Many thanks.

I fix this in a post script. (Actually, depending on the character, I only change my hands. Sometimes I leave the feet in world orientation.)

This is an extract from the actual script I run, so do test it yourself. But this snippet seems to work on the biped template.

handRef” and “footRef” should be nodes that match the orientation you want in your rig. Make sure to choose something that makes sense for those 2 lines.

import pymel.core as pm
from mgear.core import attribute, transform
from mgear import rigbits

for side in "LR":
    # Orient the IK hands
    handRef = pm.PyNode('arm_{}0_fk2_ctl'.format(side))
    ikCns = pm.PyNode('arm_{}0_ikcns_ctl'.format(side))
    ikCtrl = pm.PyNode('arm_{}0_ik_ctl'.format(side))
    handChildren = ikCtrl.getChildren(type='transform')
    pm.parent(handChildren, None)
    transform.matchWorldTransform(handRef, ikCns)
    transform.matchWorldTransform(handRef, ikCtrl)
    # Add an offset to zero out the controls.
    rigbits.addNPO(ikCns)
    pm.parent(handChildren, ikCtrl)

    # Orient the IK feet.
    footRef = pm.PyNode('foot_{}0_roll_ctl'.format(side))
    ikCns = pm.PyNode('leg_{}0_ikcns_ctl'.format(side))
    ikCtrl = pm.PyNode('leg_{}0_ik_ctl'.format(side))
    footChildren = ikCtrl.getChildren(type='transform')
    pm.parent(footChildren, None)
    transform.matchWorldTransform(footRef, ikCns)
    transform.matchWorldTransform(footRef, ikCtrl)
    # Add an offset to zero out the controls.
    rigbits.addNPO(ikCns)
    pm.parent(footChildren, ikCtrl)
5 Likes

Thank you very much! It really works! Only, after this script, the “mirror” on the legs does not work correctly

1 Like

Thanks, I’ll check that out and see if I can fix it. I never noticed that.