PDA

View Full Version : isolateSelect toggle


lowkey
01-29-2006, 01:40 PM
Hi all,

I'm currently trying to implement my very first custom script, which should toggle isolateSelect on selected objects. I know it's very basic, but somehow I can't get it to work.

Right now, the toggle works for the selected modelPanel, but the selected objects are not added to the isoView:

string $panelName = `getPanel -wf`; //get panel with focus
int $isoState = `isolateSelect -q -state $panelName`; //get state for isolate select

if ( $isoState == 0 )

{
isolateSelect -state 1 $panelName; //enable isolateSelect
isolateSelect -loadSelected ($gReferenceEditorModelEditor);
}

else

{
isolateSelect -state 0 $panelName; //disable isolateSelect
isolateSelect -loadSelected ($gReferenceEditorModelEditor);
};
Can someone please help? :shrug:

lowkey
01-29-2006, 01:58 PM
OK, I solved it myself. Not sure, if it's the most elegant solution though:
string $panelName = `getPanel -wf`;
int $isoState = `isolateSelect -q -state $panelName`;

if ( $isoState == 0 )
{
enableIsolateSelect $panelName 1;
isolateSelect -state 1 $panelName;
isolateSelect -loadSelected ($gReferenceEditorModelEditor);
}

else

{
enableIsolateSelect $panelName 0;
isolateSelect -state 0 $panelName;
isolateSelect -loadSelected ($gReferenceEditorModelEditor);
};

And what is this here? Some kind of global procedure/variable?
$gReferenceEditorModelEditor

tciny
01-29-2006, 02:39 PM
If youre not sure about where a function or variable comes from try whatIs() on it.

lowkey
01-29-2006, 02:43 PM
Thanks for your advice, but it somehow returns "Unkown" as result.

Mikademius
01-29-2006, 10:22 PM
Hi lowkey :)
I don't have Maya in front of me now, but I've been thinking:
- You're creating a toggle. The shortest way to write a toggle would be to say. "This trigger will do the opposite as my query returns.".

can't you write it like this? Or simular?:

string $getPanel = `getPanel -wf`;
int $isoState = `isolateSelect -q -state $getPanel`;
isolateSelect -state (!$isostate);


I haven't ried it, just theoretical thoughts :) . Not sure the simple ! will work. I was thinking "Just query the state and do what it's not returning".... Try it out :)
p.s. you could probably even query the state inside the "()". And say "not result of query" as the command.

$gReferenceEditorModelEditor
variables written with a g are global strings yes.

lowkey
01-30-2006, 07:36 AM
Well, I see where you are pointing at and it seems to be a good idea to reduce the code like this. Unfortunately it does not work and I'm too much of a noob to be able to figure it out. :(

On top of that I just noticed that my initial script (previous post) only works in the scene, where I created it first. Why is that? I mean, I can't see any scene specific variables in it? :shrug:

Thanks for your time, guys!

lowkey
01-30-2006, 07:41 AM
OK, now it's working. I had to change the global variable $gReferenceEditorModelEditor to $panel:

string $panelName = `getPanel -wf`;
int $isoState = `isolateSelect -q -state $panelName`;

if ( $isoState == 0 )
{
enableIsolateSelect $panelName 1;
isolateSelect -state 1 $panelName;
isolateSelect -loadSelected ($panelName);
}

else

{
enableIsolateSelect $panelName 0;
isolateSelect -state 0 $panelName;
isolateSelect -loadSelected ($panelName);
}; Anyway, I'd still love to see how to implement this using the NOT operator.

Mikademius
01-30-2006, 11:16 AM
You can do it like this:


string $panelName = `getPanel -wf`;
int $isoState = `isolateSelect -q -state $panelName`;

enableIsolateSelect $panelName 1;
isolateSelect -state (!$isoState) $panelName;
isolateSelect -loadSelected ($panelName);



I am currently trying to get the query in the command as well, but that's a starter. Lemme see if I can figure it out.

Mikademius
01-30-2006, 11:23 AM
How about this:


string $panelName = `getPanel -wf`;
isolateSelect -state (!`isolateSelect -q -state $panelName`) $panelName;
isolateSelect -loadSelected ($panelName);

lowkey
01-30-2006, 11:25 AM
Wow, the whole thing got so much simpler just by using the NOT-operator! Still so much to learn... *sigh* ;)

Mikademius
01-30-2006, 11:37 AM
Hehe, yeah... It's funny to look at old scripts and see all the lines one typed in to get a simple operation going :) A lot of headbanging there.

CGTalk Moderation
01-30-2006, 11:37 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.