PDA

View Full Version : Checking Part of a Name


Dustin
10-18-2010, 03:23 AM
Alrighty, so I am trying to create a script where if you select a control for the current character's finger, and click a button, the script will select that same control on all the other fingers of that character.

What would be great is if I could do this:

string $rigName = "rig_name";
string $control[] = `ls -sl`;
if ($control[0] == ($rigName[0] + "_lFinger*J1C"))
{
select {$rigName[0] + "_lFinger*J1C"};
}

But using the asterisk doesn't work in the third line. I am relatively new to this stuff, so I am just wondering why this doesn't work and what my other options might be. The number of fingers is customizable, so it would be tedious to have to check whether every finger control is selected.

Morganism
10-18-2010, 05:18 AM
check out the gmatch mel command in the docs, I think that's probably what you're looking for.

ewerybody
10-18-2010, 10:18 AM
Its always confusing me. gmatch and match have twisted inputs:
gmatch that *onThisExpression*;
match *withThisExpression* onThat;

so if your name is like: rig_name_lFinger1J1C:{
string $rigName = "rig_name";
string $control[] = `ls -sl`;
if (`gmatch $control[0] ($rigName + "_lFinger*J1C")`)
{
print "YEA!";
}
}

Robert Bateman
10-18-2010, 10:23 AM
What would be great is if I could do this:


You can - if you use the correct bracket type.


string $rigName = "rig_name";
string $control[] = `ls -sl`;
if ($control[0] == ($rigName[0] + "_lFinger*J1C"))
{
select ($rigName[0] + "_lFinger*J1C");
}

ewerybody
10-18-2010, 03:34 PM
hehe :D I actually haven't seen that the brackets were wrong.
but why selecting something anyway if its already selected? ;]

(i know thats not the point. Just kidding)

Dustin
10-18-2010, 04:21 PM
hehe :D I actually haven't seen that the brackets were wrong.
but why selecting something anyway if its already selected? ;]

(i know thats not the point. Just kidding)

Yeah, the brackets don't make a difference, the gmatch is the way to go, thanks everyone!

Just to give context, the script checks to see if one type of control is selected, and then it selects all the other controls with the similar name.

CGTalk Moderation
10-18-2010, 04:21 PM
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.