I'm trying to loop through all selected joints, and for each iteration, create a pairBlend node and connect it to the related joints.
Code is:
Code:
proc EdSplitJointChain(string $splitJoints[]) { group -n blendChains_grp $splitJoints[0]; rename $splitJoints[0] "result_root_jnt"; group -n result_grp result_root_jnt; string $resultChain[] = `listRelatives -ad result_grp`; duplicate -rc result_grp; searchReplaceNames "result" "a" "hierarchy"; string $aChain[] = `listRelatives -ad "a_grp*"`; duplicate -rc -n b_grp result_grp; select b_grp; searchReplaceNames "result" "b" "hierarchy"; string $bChain[] = `listRelatives -ad "b_grp*"`; int $size = size($resultChain); int $i = 0; string $chainBlend[]; for($i; $i<$size; ++$i) { $chainBlend[$i] = `shadingNode -asUtility pairBlend -n ("chainPairBlend"+$i) `; connectAttr -f ($aChain[$i]).rotate ($chainBlend[$i]).inRotate1; connectAttr -f ($bChain[$i]).rotate ($chainBlend[$i]).inRotate2; connectAttr -f ($chainBlend[$i]).outRotate ($resultChain[$i]).rotate; } }
I have problems in the loop section. No matter what I do, I get an error with the name of the shading node: "Invalid object or value: chainPairBlend0"
I've tried changing the order, using a blendColors instead, and still I get the error. I'm mirroring the exact syntax that gets shown in the script history when I do it by hand, I'm just substituting the names with the positions in the $chainBlend[] array.
I know the script is very messy - I'm not good at coding, so any advice is appreciated.
Thanks very much for your help.