Change IK arm's parent while keeping the position


#1

Hey everybody,
As the title states, I’m rigging a character where I want to add an option by which you can change the parent of the IK hand manipulator allowing the option of having the hand IK manipulator follow the rotation/position of the clavicle joint or not follow any joint at all. Now, that part is fairly easy using set driven keys to animate the weights on orient/point constraints but where I’m running into a problem is whenever I switch the parent, the location of the the manipulator changes (due to the different parent). What I would like to have is that when I switch, the position of the manipulator should stay the exact same. The only technique that I have found to solve this problem is apparently not working with referencing/importing which doesn’t work for me.

If I’m not mistaken, if there’s a technique that allows for IK to FK matching, that may be workable in this situation and used for the purpose of switching parents as well.

If this has been answered recently, I apologize but the searches turned up empty.

Thanks in advance!


#2

Something like this would be accomplished through a script/scriptNode/scriptJob. Basically you need to store the control’s world space before the parent switch, make the parent switch and then switch the control’s position from the stored worldspace coordinates.

// get the worldspace coordinates
    float $pos[] = `xform -q -worldSpace -rotatePivot [i]theNameOfYourControl[/i]`; 
    float $rot[] = `xform -q -worldSpace -rotation [i]theNameOfYourControl[/i]`;
    
    // change the parent switch attribute
   setAttr [i] theNameOfYourControl.yourParentAttr aValue[/i];
   
   // move and rotate the control back to where it was
   move -rotatePivotRelative $pos[0] $pos[1] $pos[2] [i]theNameOfYourControl[/i];
    rotate -absolute -worldSpace $rot[0] $rot[1] $rot[2] [i]theNameOfYourControl[/i];

All of the stuff in italics will need your input based on your naming conventions.


#3

Will this work with referencing/importing, particularly referencing? Since the namespace changes whenever you reference a scene, will this trip up the script when it looks for the name of the control?


#4

Well I’m not sure what your final setup will be with regards to the script. Will it be some standalone tool for parent switching to work with any of your rigs, or will it be built into the rig file itself via a scriptNode? Regardless, if you specify the namespace directly for the control name in the script it will work. Or, you can include a means to get the namespace of the current selection and use that to build the name of the controls within the script.

// explicitly declare the namespace of your character
string $ns = "myCharactersNamespace:";

// OR

// get the namespace of the selected control
string $sel[] = `ls -sl`;
string $ns = `match "^.*:" $sel[0]`;

string $Rshoulder = ($ns+"R_FK_shoulder_ctrl");
string $Lshoulder = ($ns+"L_FK_shoulder_ctrl");
// etc.

Hope that helps.


#5

This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.