Maya 2020 fundamentals - modelling the real world
Get halfway through a model and find it's an unworkable mess? Can't add edge loops where you need them? Can't subdivide a mesh properly? If any of this sounds familiar check this course out.
# 1 31-08-2017 , 11:54 AM
Registered User
Join Date: Aug 2017
Posts: 1

ConnectAttr loop gives Invalid Object error with PairBlend nodes

I'm working on a script to split a joint chain into a blended pair, for use in Fk IK system.

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;
    }
   
}
where $splitJoints[] is the original chain to be split.
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.

Posting Rules Forum Rules
You may not post new threads | You may not post replies | You may not post attachments | You may not edit your posts | BB code is On | Smilies are On | [IMG] code is On | HTML code is Off

Similar Threads