Pages

Wednesday, September 16, 2009

Applying Color to Lights


Always nice to meet fellow countryman. Dimitar Nenov (new coder on ScriptSpot.com) is my fellow citizen too. He is form Sofia, Bulgaria. Ok, It might not be interesting for you.

Dimitar works on script converter "Kelvin T to Light Color" and he accepts comments and advice, so I wrote a code snippet to help him. Maybe other max-coders will be interested about the code:
on applybutton pressed do
(
for obj in lights where obj.isSelected do
if isProperty obj #rgb do
obj.rgb = rgbcolor.color
)

...but it is better if you read the comments on site and to interpret the content of the script. Well, "applybutton" is the name of the button, and the snippet is inside its handler. Also "rgbcolor" here is the ColorPicker's name. If I clear the code as independent function, it will look like this:
fn applyLightsColor clr = (
for obj in lights where obj.isSelected do
if isProperty obj #rgb do obj.rgb = clr
)

Maybe this enouth, but if you like mapped functions, there you go:
mapped function applyLightsColor obj clr = (
if (superClassOf obj == lights) and \
if (obj.isSelected) and \
if (isProperty obj #rgb) do obj.rgb = clr
)

No comments:

Post a Comment

Thanks for your comment