Announcements

Between mid-October and November, the content on AREA will be relocated to the Autodesk Community M&E Hub and the Autodesk Community Gallery. Learn more HERE.

distance tool locators to position of joints

distance tool locators to position of joints

Anonymous
Not applicable
1,145 Views
1 Reply
Message 1 of 2

distance tool locators to position of joints

Anonymous
Not applicable

Hi,

I need to use the distance tool to get the distance between each joint in a joint chain (no matter how many joints is in the chain). These locators also need to have the position of each joint. 

 

So far I can get the position of the locators with my current script below, but then the distance is made from locator2 to the rest of the locators...:

Is anyone able to help me?

 

//we have a joint chain name spine_a_fk_jnt   spine_b_fk_jnt   etc

select "spine_*_fk_jnt";
string $selected[] = `ls -sl`;

 

for ($i=1; $i<size($selected); $i++)
   {
   float $pos[] = `xform -q -ws -t $selected[$i]`;
   distanceDimension -sp $pos[0] $pos[1] $pos[2] -ep $pos[3] $pos[4] $pos[5] ;
   }

parent "locator2" "spine_a_fk_jnt";
select -r "locator2";
setAttr "locator2.translateX" 0;
setAttr "locator2.translateY" 0;
setAttr "locator2.translateZ" 0;

0 Likes
Accepted solutions (1)
1,146 Views
1 Reply
Reply (1)
Message 2 of 2

rajasekaransurjen
Collaborator
Collaborator
Accepted solution

Hi,

Hope this will help

 

 

select "spine_*_fk_jnt";
string $selected[] = `ls -sl`;
for ($i=0; $i<size($selected); $i++)
   {
       string $Child[] = `ls -dag -typ "joint" $selected[$i]`;
       int $j;
       for($j=0; $j<(size($Child)-1); $j++)
       {
            float $pos1[] = `xform -q -ws -t $Child[$j]`;
            float $pos2[] = `xform -q -ws -t $Child[$j+1]`;
            string $distNode = `distanceDimension -sp $pos1[0] $pos1[1] $pos1[2] -ep $pos2[0] $pos2[1] $pos2[2]`;
            string $loc[] = `listConnections $distNode`;
            parent $loc[0] $Child[$j];
            if(size($Child)==($j+2))
            {
                parent $loc[1] $Child[$j+1];
                
            }
       }
 
   
   }

 

 

 

 

Best Regards,

 

Rajasekaran

 

0 Likes