Light Values Script

Here goes one simple script for you guys to chew. It basically sets up a window UI to change Intensity and color of the Lights in the scene. Just copy it from the script editor to your shelf. It loads all your lights in the scene to the list. Then select the lights you want to change settings (it allows multiple selection).

Later i will introduce specular,diffuse, depth map shadows and raytrace shadow options.

in the meantime, enjoy it.

cheers

import maya.cmds as cmds

initiallightList=cmds.ls(type="light")
lightArray=[]

def Lighter():
    for o in lightArray:
        print lightArray
        iniVal= cmds.getAttr(o+".intensity")
        iniRGB = cmds.getAttr(o+".color")
        value=cmds.floatSliderGrp(newVal,query=True,value=True)
        colorRGB=cmds.colorSliderGrp (RGB, query=True, rgbValue=True)
        cmds.setAttr(o+".intensity",value)
        cmds.setAttr(o+".colorR",colorRGB[0])
        cmds.setAttr(o+".colorG",colorRGB[1])
        cmds.setAttr(o+".colorB",colorRGB[2])

def index():
    indexl=cmds.textScrollList(lista, q=True,si=True)
    del lightArray[:]
    for i in range(len(indexl)):
        lightArray.append(indexl[i])
        cmds.select(indexl[i])

#window UI
LightWindow=cmds.window(title="Light Values",w=150)
cmds.columnLayout(w=150,adj=True)
lista=cmds.textScrollList(height=150, ams=True, da=True,sc="index()")
for each in initiallightList:
    cmds.textScrollList(lista,edit=True,append=each)

cmds.frameLayout(label="Adjust Settings for selected Lights",w=150)
newVal=cmds.floatSliderGrp(label="Intensity",w=150,cal=(1,"left"),pre=2,adj=1,field=True)
RGB=cmds.colorSliderGrp(label="color RGB",cal=(1,"left"),adj=True)
cmds.setParent('..')
cmds.rowLayout()
cmds.setParent('..')
cmds.button(label="Apply",c="Lighter()")
cmds.button(label="Close", c="cmds.deleteUI(LightWindow)")
cmds.setParent('..')

cmds.showWindow(LightWindow)
Advertisements

One thought on “Light Values Script

  1. Hey, first off, Thanks for a great blog. I’ve learned a good amount!

    My suggestion would be to use the command “attrControlGrp” in this case, to get a direct link between your UI and the lights. Check it out! 🙂
    Again, Thanks for a great blog!

    Regards, Jakob

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s