PDA

View Full Version : Adding isolateSelect in different modelPanels??


RavenEye
10-25-2007, 06:15 PM
I've created a modeling tools menu script for our in house modeler. I have all the tools that he wanted and have them working. But, he came to me and asked if I could add the isolate select command to the script. Of course I said sure and was proud of myself for getting it to work.

global proc viewSel()
{
string $getPanel[] = `getPanel -type modelPanel`;
if(`menuItem -query -checkBox viewSelect` == 1)
{
enableIsolateSelect modelPanel1 1;
isolateSelect -state 1 modelPanel1;
}
else
if(`menuItem -query -checkBox viewSelect` == 0)
{
enableIsolateSelect modelPanel1 0;
isolateSelect -state 0 modelPanel1;

}

}

global proc addSelObj()
{

addSelectedToEditor modelPanel1;
isolateSelect -state 1 modelPanel1;
}


Just one thing, it only works in modelPanel1. Now, I'm thinking I have to create a loop that checks for what panel the user is in. This is where I'm stumped at. I'm not sure how to create or word the loop to check which panel the user is using.

I tried using an if-else statement using the modelPanel command but that didn't work. I'm unsure how to use the getPanel command. The maya mel Command help doc is pretty vague on that one. So, I'm asking for help.

huangzhen023
10-28-2007, 12:30 PM
$x = `isolateSelect -q -state modelPanel4`;
$y = pow(($x-1),2);
enableIsolateSelect modelPanel1 $y;
isolateSelect -state $y modelPanel1;
isoSelectAutoAddNewObjs modelPanel1 $y;
enableIsolateSelect modelPanel2 $y;
isolateSelect -state $y modelPanel2;
isoSelectAutoAddNewObjs modelPanel2 $y;
enableIsolateSelect modelPanel3 $y;
isolateSelect -state $y modelPanel3;
isoSelectAutoAddNewObjs modelPanel3 $y;
enableIsolateSelect modelPanel4 $y;
isolateSelect -state $y modelPanel4;

thematt
10-28-2007, 09:37 PM
instead of doing it with modelpanel1, simply find the modelpanel under the mouse and put it into a variable.

use that for it

string $currPanel = `getPanel -withFocus`


cheers

teacup
10-29-2007, 02:43 PM
I'll also add that when using 'getPanel -withFocus` you'll also need to check that the panel returned is one of the model panels, as this will also return things like uveditor or hypershade.

strarup
11-02-2007, 08:13 AM
Hi,


well can see some of this aolready has been posted... but to lazy to go edit the text here... :)

well you can either use the withFocus or underPointer flag... and then check if that is a modelPanel...
well as so many other things in mel there are more than one way to do it...
or get the info...

here are some different examples...

string $daPanels[] = `getPanel -all`;

//which modelpanel's does exist returns a list of the modelPanels that exists
string $daModelPanels[] = `getPanel -type modelPanel`;
which I can see you also have used in your script...
I'm not sure if I would go for the loop thing...
however I'm not sure how your complete script works and how it appears for the user to use it...
have made an example on how to use it in a loop a bit further down...

//which panel has focus...
string $daPanelWithFocus = `getPanel -wf`;
//what is the type of the panel with focus by using eval
string $daTypeOfPanelWfocus = eval("getPanel -to `getPanel -wf`");
//or just by the former result by query the with focus thingie...
string $daTypeOfPanelWfocus = `getPanel -to $daPanelWithFocus`;

//which panel underpointer... sometimes a bit more tricky to use than the withFocus
string $daPanelUnderPointer = `getPanel -up`;

//get the label of the panel with focus...
modelPanel -q -l `getPanel -wf`;
//and you can also use the panel cmd instead of the modelPanel cmd
panel -q -l `getPanel -wf`;
the label is mostly only useful if you make your own panels... e.g. a tearoff modelPanel...
or if you wanna base it on the viewpanes...

or depending on the viewpanes use the -pane(nr) flag
e.g. like this will return name from -pane1 flag..
paneLayout -query -pane1 viewPanes

//parent layout
modelEditor -q -p `getPanel -wf`;

//which modelEditor is contained by the panel
modelPanel -q -me `getPanel -wf`;

//to check if e.g. modelPanel1 is the active view...
modelEditor -q -av modelpanel1;

//isolate selected in the panel with focus if it's a modelpanel...
modelEditor -e -vs 1 -ss -as `getPanel -wf`;

in your case I think I would go with the withFocus thingie... and also include a check
to see if it's a modelPanel...


global proc viewSel()
{
string $getDaPanel[] = `getDaPanelWFandType`;
string $daPanelWithFocus = `getPanel -wf`;
string $daTypeOfPanelWfocus = `getPanel -to $daPanelWithFocus`;

if($getDaPanel[1] == "modelPanel")
{
if(`menuItem -query -checkBox viewSelect` == 1)
{
enableIsolateSelect $getDaPanel[0] 1;
isolateSelect -state 1 $getDaPanel[0];
}
else if(`menuItem -query -checkBox viewSelect` == 0)
{
enableIsolateSelect $getDaPanel[0] 0;
isolateSelect -state 0 $getDaPanel[0];
}
}
else {warning "panel isn't a modelPanel";}
}

global proc addSelObj()
{
string $getDaPanel[] = `getDaPanelWFandType`;
if($getDaPanel[1] == "modelPanel")
{
addSelectedToEditor $getDaPanel[0];
isolateSelect -state 1 $getDaPanel[0];
}
else {warning "panel isn't a modelPanel";}
}

global proc string[] getDaPanelWFandType()
{
//get the panel with focus and return
//it together with it's type...
string $daPanelArr[];
$daPanelArr[0]= `getPanel -wf`;
$daPanelArr[1]= `getPanel -to $daPanelArr[0]`;
return $daPanelArr;
}



however you can also make your own UI with a modelPanel in it if you want...
e.g. I once made a UI to switch between the different camera in scenes
where the UI both had a selectionlist a modelpanel and some other stuff...
kinda like a tearoff modelPanel...

if you wanna use a loop you can e.g use the query active flag of the modelEditor
based on the list of modelPanels... like the following example...


global proc viewSel()
{
string $daModelPanel = `daActiveModelPanel`;
if(`menuItem -query -checkBox viewSelect` == 1)
{
enableIsolateSelect $daModelPanel 1;
isolateSelect -state 1 $daModelPanel;
}
else if(`menuItem -query -checkBox viewSelect` == 0)
{
enableIsolateSelect $daModelPanel 0;
isolateSelect -state 0 $daModelPanel;
}
}

global proc addSelObj()
{
string $daModelPanel = `daActiveModelPanel`;
addSelectedToEditor $daModelPanel;
isolateSelect -state 1 $daModelPanel;
}

global proc string daActiveModelPanel()
{
string $daModelPanels[] = `getPanel -type modelPanel`;
string $daActiveMpanel = "";
for($i=0; $i<size($daModelPanels); $i++)
{
int $active = `modelEditor -q -av $daModelPanels[$i]`;
if($active != 0)
{
$daActiveMpanel = $daModelPanels[$i];
break;
}
}
return $daActiveMpanel;
}


hope it helps a bit... :)

regards

Strarup

CGTalk Moderation
11-02-2007, 08:13 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.