PDA

View Full Version : Question about Selecting a Hierarchy


EightBit
04-28-2008, 07:01 PM
I have a quadruped rig and I'd like to write a script which will select the hierarchy below the selected joint and toggle ghosting.
Because ghosting slows Maya down, I want to select only the joints which are being animated, so during the selection process I want add a filter for a specific string in the name.
The following code will select the hierarchy of joints below the selection and filter for the string "Tail". It works in a simple scene://Select hierarchy then Search/Print Joints w/specificed name
select -hi;
string $letters = "Tail";
ls -sl -type joint ("*"+$letters+"*");
But the string filter fails in the rig I'm working with. The reason for the failure has to do with the hierarchy of the scene, but I don't know how why.
When I list the joints, a ":" appears in the results, ie://Results
Rig_0:ct_Tail8_C Rig_0:ct_Tail9_C
Model_0:jt_Tail0_C Model_0:jt_Tail1_C...
But when I try to filter these results for the string "Tail", nothing is returned.
What I'd like to know is why does the ":" appear in the listing and how do I work around this?
Thanks.

EGGer
04-29-2008, 06:58 AM
I have a quadruped rig and I'd like to write a script which will select the hierarchy below the selected joint and toggle ghosting.
Because ghosting slows Maya down, I want to select only the joints which are being animated, so during the selection process I want add a filter for a specific string in the name.
The following code will select the hierarchy of joints below the selection and filter for the string "Tail". It works in a simple scene://Select hierarchy then Search/Print Joints w/specificed name
select -hi;
string $letters = "Tail";
ls -sl -type joint ("*"+$letters+"*");
But the string filter fails in the rig I'm working with. The reason for the failure has to do with the hierarchy of the scene, but I don't know how why.
When I list the joints, a ":" appears in the results, ie://Results
Rig_0:ct_Tail8_C Rig_0:ct_Tail9_C
Model_0:jt_Tail0_C Model_0:jt_Tail1_C...
But when I try to filter these results for the string "Tail", nothing is returned.
What I'd like to know is why does the ":" appear in the listing and how do I work around this?
Thanks.

The string before ":" is nameSpace string. It will be added in a node name when you import or create reference files which includes the same node name.

-> a solution:
...
... ...
string $getSel[] = `ls -sl -type joint ("*"+$letters+"*")`;
string $loopStr;
string $tempArray[];
int $i,$numTokens;
for($i=0;$i<`size($getSel)`;$i++){
$numTokens = `tokenize $getSel[$i] ":" $tempArray`;
if($numTokens ==2){
$getSel[$i] = $tempArray[1];
}
}
print $getSel;

I have no idea whether it can be a reference for you.

CGTalk Moderation
04-29-2008, 06:58 AM
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.