# Illuminate By Default In Mel Script

**URL:** https://forum.highend3d.com/t/illuminate-by-default-in-mel-script/3180
**Category:** Maya
**Tags:** mel
**Created:** [April 7, 2006, 2:25pm UTC](https://forum.highend3d.com/t/illuminate-by-default-in-mel-script/3180 "2006-04-07T14:25:33Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![fxnurbs](https://forum.highend3d.com/user_avatar/forum.highend3d.com/fxnurbs/32/288_2.png) [@fxnurbs](https://forum.highend3d.com/u/fxnurbs)
#### Post date: [April 7, 2006, 2:25pm UTC](https://forum.highend3d.com/t/illuminate-by-default-in-mel-script/3180/1 "2006-04-07T14:25:33Z")

</div>

Hi,

I am writting a little script to disconnect and reconnect the specular, diffuse and illuminate in the lights  
i don't find the good way to write this for the illuminate by default  
here is what i wrote :

CODE  
string $sel[] = `ls -sl`;  
for( $item in $sel)  
{  
setAttr ($item+".emitSpecular") 0;  
};

but the fonction in the illuminate is more complexe and i don't find the good one

Somebody can help me ?

oh, i want to put all of that in a window, but i only know the simple button fonction  
what is the fonction to have a radio button boolean ?

Thanks, Jaz

---

<div class="post-metadata">

### Author: ![rob-bateman](https://forum.highend3d.com/letter_avatar_proxy/v4/letter/r/4491bb/32.png) [@rob-bateman](https://forum.highend3d.com/u/rob-bateman)
#### Post date: [April 7, 2006, 4:32pm UTC](https://forum.highend3d.com/t/illuminate-by-default-in-mel-script/3180/2 "2006-04-07T16:32:11Z")

</div>

The way maya does this is slightly long winded, however there is a nice way to do it....

CODE  
string $sel[] = `ls -sl`;  
for( $item in $sel)  
{  
&nbsp;&nbsp;// fine to set these to 0 or 1  
&nbsp;&nbsp;setAttr ($item+".emitSpecular") 0;  
&nbsp;&nbsp;setAttr ($item+".emitDiffuse") 0;

&nbsp;&nbsp;// illuminates By Default, essentially connects or disconnects the light from the default light  
&nbsp;&nbsp;// set. The easiest way is to simply edit the object set and remove the light from it  
&nbsp;&nbsp;sets -e -remove "defaultLightSet" $item;  
};

CODE  
string $sel[] = `ls -sl`;  
for( $item in $sel)  
{  
&nbsp;&nbsp;// fine to set these to 0 or 1  
&nbsp;&nbsp;setAttr ($item+".emitSpecular") 1;  
&nbsp;&nbsp;setAttr ($item+".emitDiffuse") 1;

&nbsp;&nbsp;// add the light into the set...  
&nbsp;&nbsp;sets -e -add "defaultLightSet" $item;  
};

QUOTE  
oh, i want to put all of that in a window, but i only know the simple button fonction  
what is the fonction to have a radio button boolean ?

the checkBox mel command should have a little example a the bottom of the mel docs that should be fairly straightforward. Radiobuttons are a bit annoying in my opinion, and possibly more than you need....

---

<div class="post-metadata">

### Author: ![fxnurbs](https://forum.highend3d.com/user_avatar/forum.highend3d.com/fxnurbs/32/288_2.png) [@fxnurbs](https://forum.highend3d.com/u/fxnurbs)
#### Post date: [April 8, 2006, 8:20pm UTC](https://forum.highend3d.com/t/illuminate-by-default-in-mel-script/3180/3 "2006-04-08T20:20:03Z")

</div>

Thanks a lot, it helps me a lot.

Here is the script i wrote with (a window where you can choose to add or remove illuminate, specular and diffuse)  
there a little unused argument but who don't trouble anything, i just didn't know how to write exacly.  
It works perfectly with no error message so... that the most imortant.

thanks again

CODE  
window -title "Add&Remove light radio" -rtf true thelightsWin;

rowColumnLayout -numberOfColumns 4;

string $t = `text -l "Remove Chanels :"`;

button -label "Illuminate" -c "offIllum remove" killI;  
button -label "Diffuse" -c "attRemover emitDiffuse" killD;  
button -label "Specular" -c "attRemover emitSpecular" killS;

string $t = `text -l "Calling Chanels :"`;

button -label "Illuminate" -c "addIllum add" backI;  
button -label "Diffuse" -c "attCalling emitDiffuse" backD;  
button -label "Specular" -c "attCalling emitSpecular" backS;

showWindow thelightsWin;

proc attRemover( string $theLight ) {

string $theSelection[] = `ls -sl`;

for ($theNode in $theSelection){

&nbsp;&nbsp; setAttr ($theNode + "."+$theLight) 0;

}}

proc attCalling( string $theLight ) {

string $theSelection[] = `ls -sl`;

for ($theNode in $theSelection){

&nbsp;&nbsp; setAttr ($theNode + "."+$theLight) 1;

}}

proc offIllum( string $theLight ) {

string $theSelection[] = `ls -sl`;

for ($theNode in $theSelection){

&nbsp;&nbsp; sets -e -remove "defaultLightSet" $theNode;

}}

proc addIllum( string $theLight ) {

string $theSelection[] = `ls -sl`;

for ($theNode in $theSelection){

&nbsp;&nbsp; sets -e -add "defaultLightSet" $theNode;

}}
