Maya for 3D Printing - Rapid Prototyping
In this course we're going to look at something a little different, creating technically accurate 3D printed parts.
# 1 14-10-2014 , 03:13 PM
Registered User
Join Date: Oct 2014
Posts: 1

Hide Selected Faces

I'm trying to create two simple scripts in Maya '12 to replicate the "Hide Selected" faces and "Unhide All" functions from Max. I have minimal Maxscript and programming experience, and even though I think I've got the logic right the script only seems to work sometimes, but most of the times it will just hide every face.

Code:
// Hide Selected
invertSelection;
$currentPanel = `getPanel -withFocus`;
string $panelType = `getPanel -to $currentPanel`;
if ($panelType == "modelPanel") {
isolateSelect -state 1 $currentPanel;
}
select -cl;
Code:
// Unhide All
$currentPanel = `getPanel -withFocus`;
string $panelType = `getPanel -to $currentPanel`;
if ($panelType == "modelPanel") {
isolateSelect -state 0 $currentPanel;
}
Does anyone know what it is that I'm doing wrong? Thanks in advance.

# 2 14-10-2014 , 10:23 PM
Gen's Avatar
Super Moderator
Join Date: Dec 2006
Location: South FL
Posts: 3,522
I'm guessing you'd like a fast way to toggle isolate selection. Another if statement nested in your "if ($panelType == "modelPanel") " block that queries the state of isolate select and changes the value accordingly would eliminate the need for another script. This is the script I use, I have it bound to a mouse button.
Code:
////////////////////////////////////////////////////////////
// Toggles isolate select

{
        
        // get panel that is under the mouse pointer.
        string $currentPanel = `getPanel -up`;
        
        // if none available, get panel with focus.
        if ($currentPanel == "")
                $currentPanel = `getPanel -wf`;
        
        // make sure panel is indeed a modeling panel.
        if (`getPanel -to $currentPanel` == "modelPanel"){
               
		// if isolate selection is on, turn it off
                if (`isolateSelect -q -state $currentPanel`){
                        isolateSelect -state 0 $currentPanel;                           
                }else{
			//else turn on
                        enableIsolateSelect $currentPanel 1;
                        isoSelectAutoAddNewObjs $currentPanel 1;
                        isolateSelect -state 1 $currentPanel;
                }
        }
        
}


- Genny
__________________
::|| My CG Blog ||::
::|| My Maya FAQ ||::
Posting Rules Forum Rules
You may not post new threads | You may not post replies | You may not post attachments | You may not edit your posts | BB code is On | Smilies are On | [IMG] code is On | HTML code is Off

Similar Threads