how to set the default material for attrColorSliderGrp if object in null

Become a member of the CGSociety

Connect, Share, and Learn with our Large Growing CG Art Community. It's Free!

THREAD CLOSED
 
Thread Tools Search this Thread Display Modes
Old 10 October 2012   #1
Question how to set the default material for attrColorSliderGrp if object in null

def update():
	shapes = cmds.ls(sl = True, o = True, dag = True, s = True)
	shadingEngines = cmds.listConnections(shapes, type = "shadingEngine")
	materials = str(cmds.ls(cmds.listConnections(shadingEngines), materials = True)[0])
		
	return cmds.attrColorSliderGrp("attrCSldrGrp",edit= True,  at=materials+'.color' )

cmds.window( title='Attr Field Slider Groups' )
cmds.columnLayout()
try:
	cmds.attrColorSliderGrp("attrCSldrGrp", at='lambert1.color')
	cmds.scriptJob(parent="attrCSldrGrp",e=["SelectionChanged","update()"])
except TypeError:
	cmds.attrColorSliderGrp("attrCSldrGrp", edit=True, at='lambert1.color')
cmds.showWindow()


well in the above code I came up with if nothing is selected i get error but what i want is if nothing is selected lambert1 should get selected/assigned to attrColorSliderGrp...
 
Old 10 October 2012   #2
Why not check the length of the selected shapes and if nothing is selected directly put "lambert1" into the varaible holding the material name?
import maya.cmds as cmds
 def update():
 	shapes = cmds.ls(sl = True, o = True, dag = True, s = True)
 	if len(shapes) == 0:
 		materials = "lambert1";
 	else:
 		shadingEngines = cmds.listConnections(shapes, type = "shadingEngine")
 		materials = str(cmds.ls(cmds.listConnections(shadingEngines), materials = True)[0])
 		
 	return cmds.attrColorSliderGrp("attrCSldrGrp",edit= True,  at=materials+'.color' )
 
 cmds.window( title='Attr Field Slider Groups' )
 cmds.columnLayout()
 try:
 	cmds.attrColorSliderGrp("attrCSldrGrp", at='lambert1.color')
 	cmds.scriptJob(parent="attrCSldrGrp",e=["SelectionChanged","update()"])
 except TypeError:
 	cmds.attrColorSliderGrp("attrCSldrGrp", edit=True, at='lambert1.color')
 cmds.showWindow()
 
Old 10 October 2012   #3
Question

if things can be selected and attributes be displayed as the selection is done based on event change, why Autodesk developers of maya didnt do it this way and has made it a two step process to first select and then click on material attribute to show the panel ...?
 
Old 10 October 2012   #4
Thread automatically closed

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.
__________________
CGTalk Policy/Legalities
Note that as CGTalk Members, you agree to the terms and conditions of using this website.
 
Thread Closed share thread



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
CGSociety
Society of Digital Artists
www.cgsociety.org

Powered by vBulletin
Copyright 2000 - 2006,
Jelsoft Enterprises Ltd.
Minimize Ads
Forum Jump
Miscellaneous

All times are GMT. The time now is 06:24 AM.


Powered by vBulletin
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.