// ================================================================ // Put selected icon on selected joint // ================================================================ global proc putIconOnJoint( string $jointName, string $iconName ) { if ( !`objExists $jointName` || !`objExists $iconName` ) error ("putIconOnJoint: The joint (\"" + $jointName + "\") and/or the icon object (\"" + $iconName + "\") doesn't exist!"); string $whatType[] = `ls -dag -showType $iconName`; //print ( "\n whatType" + 3 + " = " + $whatType[1]); if ( $whatType[3] != "nurbsCurve" && `size $whatType` != 4 ) warning ("putIconOnJoint: Disregarding (\"" + $iconName + "\"), since it is NOT a \"normal\" Nurbs curve!"); else { // Get the icons's CVs position in world space. float $allIconCVs[] = `xform -q -ws -t ($iconName + ".cv[*]")`; // Parent the icon's shape to the joint (the icon will jump in space). parent -s -r ($iconName + "Shape") $jointName; // Put back each icon's CVs where it was before the shape parenting. int $CVsCount = 0; for ($i=0;$i<(`size $allIconCVs`/3);$i++) { xform -a -ws -t $allIconCVs[$CVsCount] $allIconCVs[$CVsCount+1] $allIconCVs[$CVsCount+2] ($iconName + "Shape.cv[" + $i + "]"); $CVsCount+=3; } select -r $jointName; } } //string $sel[] = `ls -sl`; //putIconOnJoint( $sel[0], $sel[1] );