PDA

View Full Version : How to I turn off my selection light sources ?


maria-taher
05-09-2010, 04:09 AM
Hello ,

I design a window and two buttons .
button names are "Off Spot Lights" and " Off Point Lights".

This is my Mel Script :

window offlights;

rowColumnLayout -nc 2 ;


button -label "Off Spot Lights";
button -label "Off point Lights";


showWindow offlights;


http://dsa7.fileflyer.com/d/e963743e-8480-4d23-afee-9a822c395816/z0DR/JI4LaA6/01.png


I have some light sources in my viewport and I selected them.


http://dsa7.fileflyer.com/d/91cdd98f-bb5f-464b-b8fe-b51d7cd5ba53/z0Di/9xSzmBv/02.png


I want to write a command for these buttons .
I want to turn off "illuminates by default" parameter only for it's light type when I click on it's button.
Such as I want to turn off "illuminates by default" parameter in attribute editor only for my spot lights when I click on "Off Spot Lights" button.

Sorry for my english.

EJ
05-09-2010, 04:53 AM
global proc turnOffLight(string $type)
{
string $lights[] = `ls -sl -dag -typ $type`;

for ($light in $lights)
{
string $lightTransform[] = `listRelatives -ni -p $light`;
string $lightSet[] = `listConnections -s 0 -d 1 -p 1 -t "objectSet" $lightTransform[0]`;
if (`strcmp "" $lightSet[0]`)
{
disconnectAttr ($lightTransform[0]+".instObjGroups[0]") $lightSet[0];
}
}
}


turnOffLight("spotLight"); // turns off illuminate by Default for spot lights
turnOffLight("pointLight"); // turns off illuminate by Default for point lights
turnOffLight("directionalLight"); // turns off illuminate by Default for directional lights
turnOffLight("ambientLight"); // turns off illuminate by Default for ambient lights
turnOffLight("areaLight"); // turns off illuminate by Default for area lights
// you can assign these commands to a button or something.

maria-taher
05-10-2010, 01:44 AM
thank you EJ , you are king of scripting.

CGTalk Moderation
05-10-2010, 01:45 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.