11 November 2010, 04:48 PM
you can see attributes in the outliner (if you turn on "Display > Attributes (channels)") which would allow users to select them easily. You could also create a very simple "picker" UI from a window with a form-attached textScrollList, that displayed a list of all custom attributes on the selected node (which you can query by: `listAttr -ud $node`). As soon as the user clicked an entry on the textScrollList you could fire off your process..?
Attributes aren't visible in the Channel Box unless they are keyable, so you could also make the custom attributes keyable and they'd show up in the channel box, but I'm not sure if that would actually work for all attr types..?
11 November 2010, 04:59 PM
Thanks a lot Nathan:
The outliner is too messy, but I like your UI idea.
I've got it mostly working but when I grab the UD Attr from the textScrollList, I get unicode and I'm having trouble converting it to a proper string - any suggestions (see the errors in the 'selectAttr' def).
winName = "tmp"
testing = False
#Delete windowPrefs when testing, might generate error if existence is not tested for also:
if (testing and windowPref(winName, exists=True)):
cmds.windowPref( winName, remove=True )
cmds.window(winName,wh=(220, 180),resizeToFitChildren=True,title="test UD Attr Picker")
cmds.text('UDAttrText',l="User Defined Attrs in Selected :")
cmds.button('getAttrsBtn',l="Get Attrs",c=lambda *args: listUDAttrs())
# EDIT formLayout
cmds.formLayout('attrForm',e=1,ap=[('UDAttrText', 'left', 0, 4), ('UDAttrsList', 'left', 0, 4), ('getAttrsBtn', 'left', 0, 4)],
ac = [ ('UDAttrsList', 'top',3, 'UDAttrText'), ('getAttrsBtn', 'top',3, 'UDAttrsList') ] )
cmds.textScrollList('UDAttrsList',e=1,ra=1) # Remove All
currObj = cmds.ls (sl=1)
UDAttrs = cmds.listAttr (currObj, ud = 1)
for currAttr in UDAttrs:
cmds.textScrollList('UDAttrsList',e=1,a=currAttr, selectCommand=lambda *args: selectAttr(currObj))
attrName = cmds.textScrollList('UDAttrsList',q=1,si=1)# Error: TypeError: coercing to Unicode: need string or buffer, list found #
#attrName = str ( cmds.textScrollList('UDAttrsList',q=1,si=1) ) # Error: TypeError: Object internalA.[u'pCube5'] is invalid #
cmds.select (currObj+'.'+attrName )
selected = cmds.ls (sl=1)
print 'attr Selected',selected
11 November 2010, 05:15 PM
I don't think unicode is a problem, querying the selected items of a textScrollList always returns a list, even with only one item selected. This is the issue I think. add  to the end:
attrName = cmds.textScrollList('UDAttrsList',q=1,si=1) # always returns a list, so grab index 
11 November 2010, 05:16 PM
That did it!
Thanks a lot for the quick reply mate!
...back to work
11 November 2010, 05:16 PM
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.