Code for the "Use All Lights" and "Use Default Lighting" commands?

Code for the "Use All Lights" and "Use Default Lighting" commands?

Anonymous
Not applicable
2,005 Views
5 Replies
Message 1 of 6

Code for the "Use All Lights" and "Use Default Lighting" commands?

Anonymous
Not applicable
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.
0 Likes
2,006 Views
5 Replies
Replies (5)
Message 2 of 6

lee.dunham
Collaborator
Collaborator
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 ;
0 Likes
Message 3 of 6

Anonymous
Not applicable
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 -e -dl "default" $currentPanel;}


Hopefully that'll help you out 🙂
0 Likes
Message 4 of 6

Anonymous
Not applicable
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 ;
}
0 Likes
Message 5 of 6

lee.dunham
Collaborator
Collaborator
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");
}
0 Likes
Message 6 of 6

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

Thanks!
0 Likes