Apophis3d
02-09-2008, 09:42 PM
I am looking for a way to link a lights intensity to a controler. Although in the linking editor I can not find an attribute for a lights intensity.
Basically this script will allow the user to selecte the lights in a scene. Then it will let the user rename the lights to whatever they want. All the lights in that scene will be able to have their intensity controled by the controler. That way you do not have to go though and selecte multipal lights.
I am not sure if I went about setting this up right. But when you run the script it should check to make sure if any lights are selected. If not it tells you none are selected. If you have a light selected it should ask you to rename the light. Then bind that lights intensity to the controler. I know I need some kind of loop but I really dont know where to go with my code i am at the point of confusion.
here is my code so far.
global proc lights(string $obj)
{
//Varables
string $sel[] = `ls -lt`;
int $num = `size($sel)`;
//creates circle
string $cir[] = `circle -normal 0 1 0 -name $obj`;
//Adds attribute
string $cir[] = `addAttr -ln "LightBrightness" -at double $obj`;
string $cir[] = `setAttr -e-keyable true ($obj+".LightBrightness")`;
//locks out unused attributes
$cir[] = `setAttr -lock true -keyable false ($obj+".sx")`;
$cir[] = `setAttr -lock true -keyable false ($obj+".sy")`;
$cir[] = `setAttr -lock true -keyable false ($obj+".sz")`;
$cir[] = `setAttr -lock true -keyable false ($obj+".rx")`;
$cir[] = `setAttr -lock true -keyable false ($obj+".ry")`;
$cir[] = `setAttr -lock true -keyable false ($obj+".rz")`;
//selects lights
if ($num == 0)
error "Nothing selected";
}
Basically this script will allow the user to selecte the lights in a scene. Then it will let the user rename the lights to whatever they want. All the lights in that scene will be able to have their intensity controled by the controler. That way you do not have to go though and selecte multipal lights.
I am not sure if I went about setting this up right. But when you run the script it should check to make sure if any lights are selected. If not it tells you none are selected. If you have a light selected it should ask you to rename the light. Then bind that lights intensity to the controler. I know I need some kind of loop but I really dont know where to go with my code i am at the point of confusion.
here is my code so far.
global proc lights(string $obj)
{
//Varables
string $sel[] = `ls -lt`;
int $num = `size($sel)`;
//creates circle
string $cir[] = `circle -normal 0 1 0 -name $obj`;
//Adds attribute
string $cir[] = `addAttr -ln "LightBrightness" -at double $obj`;
string $cir[] = `setAttr -e-keyable true ($obj+".LightBrightness")`;
//locks out unused attributes
$cir[] = `setAttr -lock true -keyable false ($obj+".sx")`;
$cir[] = `setAttr -lock true -keyable false ($obj+".sy")`;
$cir[] = `setAttr -lock true -keyable false ($obj+".sz")`;
$cir[] = `setAttr -lock true -keyable false ($obj+".rx")`;
$cir[] = `setAttr -lock true -keyable false ($obj+".ry")`;
$cir[] = `setAttr -lock true -keyable false ($obj+".rz")`;
//selects lights
if ($num == 0)
error "Nothing selected";
}
