Inside Sabertooth
Learn how Sabertooth uses 3ds Max to create 3D interactive projects, including HBO Go’s Game of Thrones interactive experience
  • 1/3
You are here: Forum Home / Autodesk® Maya® / MEL / Code for the "Use All Lights" and "Use Default Lighting" commands?
  RSS 2.0 ATOM  

Code for the "Use All Lights" and "Use Default Lighting" commands?
Rate this thread
 
63194
 
Permlink of this thread  
avatar
  • R*
  • Posted: 01 January 2012 05:37 AM
  • Total Posts: 10
  • Joined: 29 December 2011 04:20 AM

Hey

I’m trying to create a tick box in a window to control the “use all lights” and “use default lighting” commands under the “lights” tab in the viewport so when you check the box, the “Use All Lights in active and when you uncheck it, the “Use Default Lighting is active” But the problem is, i don’t know the code for the two operations (Use All Lights and Use Default Lighting). The script editor doesn’t show it.

Thanks.



Replies: 1
/img/forum/dark/default_avatar.png

You’ll have to turn on Echo All Commands in the Script Editor to see these sorts of things pop up.

It should throw back things like this:

{string $currentPanel = `getPanel -withFocus`;

modelEditor -edit -dl "all" $currentPanel;

modelEditor --dl "default" $currentPanel;}

Hopefully that’ll help you out :)

Author: Toggled

Replied: 03 January 2012 01:33 AM  
avatar
  • ldunham1
  • Posted: 03 January 2012 01:30 AM

this script will toggle between “use default lighting” and “Use all lights”

string $currentPanel=`getPanel -withFocus` ;
string $mode="default" ;
if(`
getPanel -to $currentPanel`=="modelPanel")
{
    
if(`modelEditor -q -dl $currentPanel`=="default")
        
$mode="all" ;
}

modelEditor 
-edit -dl $mode $currentPanel ;

the two commands you want are ($currentPanel is the panel name - use string $currentPanel=`getPanel -withFocus` ; to get the name of the highlighted panel - you might need to look into perhaps looping through all modelPanels instead if your running through a GUI)

//all lights
modelEditor -edit -dl "all" $currentPanel ;
//default lighting
modelEditor -edit -dl "default" $currentPanel ;


Lee Dunham | Character TD
ldunham.blogspot.com

Replies: 0
avatar
  • R*
  • Posted: 03 January 2012 04:29 AM

Thanks guys, however i have a problem. I have managed to get the tick box to work for the “default lighting” but not for the “use all Lights” command.

Here is my procedure for the tick box when it is checked:

// A function to be called when the checkbox is checked. 

proc on_func() (This procedure doesn't work)
{
print("checkbox on!\n");
string $currentPanel=`getPanel -withFocus` ;
string $mode="default" ;
if(`getPanel -to $currentPanel`=="modelPanel")
{
    if(`modelEditor -q -dl $currentPanel`=="default")
        $mode="all" ;
}

modelEditor -edit -dl $mode $currentPanel ;
}

modelEditor -edit -dl $mode $currentPanel ;
}


Replies: 0
avatar
  • ldunham1
  • Posted: 03 January 2012 04:44 AM

you have a few mistakes there, it should look like this.

proc on_func()
{
    
print("checkbox on!\n");
    
string $currentPanel=`getPanel -withFocus` ;
    
string $mode="default" ;
    if(`
getPanel -to $currentPanel`=="modelPanel")
    
{
        
if(`modelEditor -q -dl $currentPanel`=="default")
            
$mode="all" ;
        
modelEditor -edit -dl $mode $currentPanel ;
    
}
}

but again, this will only work if you have the right panel highlighted.
If your using a custom window i doubt it will work as you want.
if that is the case use this (which toggles the lighting for all modelPanels)

proc on_func()
{
    string $allPanels[]
=`getPanel -type "modelPanel"` ;
    
string $mode="default" ;
    for(
$panel in $allPanels)
    
{
        
if(`modelEditor -q -dl $panel`=="default")
            
$mode="all" ;
        
modelEditor -edit -dl $mode $panel ;
    
}
    
print("checkbox on!\n");
}


Lee Dunham | Character TD
ldunham.blogspot.com

Replies: 1
/img/forum/dark/default_avatar.png

It works. Just in time for my Uni deadline next week! Now on to the report…

Thanks!

Author: R*

Replied: 03 January 2012 05:00 AM