PDA

View Full Version : Selection leading to another * selection


... Darkseed
03-21-2006, 08:09 PM
First post.

The title says it all I think. I'm trying to write a script or an expression so that when I select whatever(an object for instance) it will Deselect the currently selected object and select what I specified in the script.

thanks

EigenPuff
03-22-2006, 01:02 AM
I'm not sure what exactly you are looking for; but select should select a new selection set everytime it is invoked with out any qualifiers. -cl flag will clear it; -add will allow you to add new objects to the set with out losing the previous set.

Is something like this what you are looking for?


//copy the current selection set
string $selectionset[] = `ls -sl`;

//clear the current selection set
select -cl;

for($obj in $selectionset)
{
string $newobject = GetNewObject($obj)

//build up a new selection set based on the previous one
// ... somehow
select -add newObject;
}

//copy the current selection set again
string $selectionset2[] = `ls -sl`;

//... execute some command that requires objects to be selected

john_homer
03-22-2006, 02:44 AM
i think waht he is asking is more... click on 1 object to select another...

you may need to use a scriptJob for that...
I would set up your objects with a connection to the target so that can be queried in the scriptJob rather than having it all in a script though..

ie..
rather than.. in the scriptJob...
if my selection is this.. select A..
if my selection is that.. select B..
if my selection is whatever.. select C......

set up a connection from each selection object to each target (message to isHistoricallyInteresting is a good one)

then in the scriptJob..
if my selection is one of these selection things.... select the thing connected to its message attr.

.j

... Darkseed
03-22-2006, 06:16 AM
ok I think "scriptjob" will do it but I couldn't figure it out :blush: .
I came up with a little script so that the desired object will be selected but it happens no matter what is it that I'm selecting, which obviously isn't what I'm looking for.

I have difficulties with querying strings(I'm no MEL guru so...)

lets say I have this:
string $g[] = {"pSphere1", "pSphere2"};

string $r[] = `ls -sl`;

How am I suppose to compare the two variables to see if $r contains any of the $g?
I'm getting somewhere, thanks to both of you guys.

A_New_Hope
03-22-2006, 08:36 AM
for doing what john_homer said you could to something like this
or use a switch, it works fine as long as you know what object to check.


// loop through all selected objects
for ( $objSelected in $r )
{
if( $objSelected == "pSphere1" )
{
// if pSphere1 is selected to this
}
if( $objSelected == "pSphere2" )
{
// if pSphere2 is selected to this
}
}


to just compare to strng array you could to it like this


string $g[] = {"pSphere1", "pSphere2"};

string $r[] = `ls -sl`;

// loop through all selected objects
for ( $objSelected in $r )
{
// loop through all objects compare to
for( $objList in $r )
{
// check if there is a match
if ( $objSelected == $objList )
{
print( "same object\n" );
}
}
}

... Darkseed
03-23-2006, 08:21 PM
Thanks dude, I'm on track now.

EigenPuff
03-28-2006, 09:59 PM
haha - it's bit late, but I found this:
http://www.ewertb.com/maya/mel/mel.php?howto=83

... Darkseed
03-30-2006, 06:47 AM
Thanks Mike this is great.

CGTalk Moderation
03-30-2006, 06:47 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.