CGTalk > Software > Autodesk Maya > Maya Programming
Login register
Thread Closed share thread « Previous Thread | Next Thread »  
 
Thread Tools Search this Thread Display Modes
Old 10-08-2012, 06:09 AM   #1
DEVILSAN
Earth Born>> goo.gl/mJh20
 
DEVILSAN's Avatar
portfolio
Sanjeev Kumar
MPC
India
 
Join Date: Jan 2005
Posts: 290
Question how to set the default material for attrColorSliderGrp if object in null

Code:
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-08-2012, 07:54 AM   #2
zaskar
Expert
portfolio
franky****inFourFingaz
-
Dresden, Germany
 
Join Date: Dec 2010
Posts: 321
Why not check the length of the selected shapes and if nothing is selected directly put "lambert1" into the varaible holding the material name?
Code:
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-08-2012, 11:30 AM   #3
DEVILSAN
Earth Born>> goo.gl/mJh20
 
DEVILSAN's Avatar
portfolio
Sanjeev Kumar
MPC
India
 
Join Date: Jan 2005
Posts: 290
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-08-2012, 11:30 AM   #4
CGTalk Moderation
Lord of the posts
CGTalk Forum Leader
 
Join Date: Sep 2003
Posts: 1,066,480
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


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 05:26 PM.


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