Hello all,
I have a question about making control for lights.
So I’m trying to make an UI to chage light in the specific scene.
I got to work the primary visibility contorl, and color change control
but, I can’t make the intensity to work right.
Also, Can Checkbox start with its checked when I execute?
The script goes like this.
import maya .cmds as cmds
from functools import partial
class lightUI():
def init(self, winName=“window”):
self.winTitle = “Lighting room”
self.winName = winName
def create(self):
if cmds.window(self.winName,exists=True):
cmds.deleteUI(self.winName)
cmds.window(self.winName, title=self.winTitle)
cmds.columnLayout( adjustableColumn=True )
cmds.frameLayout( label = 'File' )
cmds.button( label = 'Import scene', command=self.importScene )
cmds.frameLayout( label = 'Lighting option' )
cmds.checkBox( 'lampCt', label='Visibility', cc=self.changeVis )
cmds.colorSliderGrp( 'csg', label='Color', rgb=(1, 0.745, 0.635), columnWidth=(5, 30), cc=self.changeColor)
cmds.floatSliderGrp( 'fsg', label='Intensity', field=True, minValue=0.0, maxValue=80.0, fieldMinValue=-100.0, fieldMaxValue=100.0, value=0, cc=self.changeInt )
cmds.separator( height=10, style='singleDash' )
cmds.separator( height=10, style='singleDash' )
cmds.setParent( '..' )
cmds.setParent( '..' )
cmds.showWindow(self.winName)
##########################################################################################################################
def importScene(self,args=None):
cmds.file( 'C:\Users\DJ\Desktop\Livingroom\scenes\dj001.ma', o=True )
def changeVis(self,args=None):
if cmds.checkBox( 'lampCt', query=True, value=True ):
cmds.setAttr( 'lampLight1.visibility', 1 )
else:
cmds.setAttr( 'lampLight1.visibility', 0 )
def changeColor(self,args=None,arg=None):
cmds.colorSliderGrp( 'csg', e=True, query=True, vis=True)
rgb = cmds.colorSliderGrp( 'csg', query=True, rgb=True)
cmds.setAttr("lampLightShape1.color",rgb[0],rgb[1],rgb[2], type="double3" )
def changeInt(self,args=None):
cmds.floatSliderGrp('fsg', e=True, vis=True )
cmds.setAttr("lampLightShape1.intensity", type="dobule3" )
myLight = lightUI()
myLight.create()