def zbw_mmListCurrentMessages(tfbg, *args):
"""
lists the message attrs in the base obj and sets up rt-click menus to change them and a button to delete them
"""
if (cmds.rowColumnLayout("mmRCListLayout", q=True, ex=True)):
cmds.deleteUI("mmRCListLayout")
cmds.rowColumnLayout("mmRCListLayout", w=600, nc=3, cw=[(1, 250),(2,250),(3,100)],p="existingMessages")
#get the base object
baseObj = cmds.textFieldButtonGrp(tfbg, q=True, tx=True)
#find all attr of type message for base obj
userAttrs = cmds.listAttr(baseObj, ud=True)
#print(udAttrs)
messageAttrs = []
messageObjs = []
if userAttrs:
for attr in userAttrs:
isMsg = cmds.attributeQuery(attr, n=baseObj, msg=True)
if isMsg:
fullMsgAttr = baseObj + "." + attr
messageAttrs.append(fullMsgAttr)
targetObj = cmds.listConnections(fullMsgAttr)
if not targetObj:
targetObj = ["no Connection"]
messageObjs.append(targetObj[0])
sizeMsgs = len(messageObjs)
for i in range(0, sizeMsgs):
thisObj = messageObjs[i]
thisAttr = messageAttrs[i]
#create textField based on num already there, non-editable
attrId = "listAttrTFG" + str(i)
objId = "listObjTFG" + str(i)
buttonId = "listButton" + str(i)
cmds.separator(h=15, style="single")
cmds.separator(h=15, style="single")
cmds.separator(h=15, style="single")
#create text field for attr
cmds.textFieldGrp(attrId, p="mmRCListLayout", l=i, cw=[(1,10), (2,190)], ed=False, tx=thisAttr)
#create popup for text field
cmds.popupMenu(("attrPUM"+str(i)), b=3)
cmds.menuItem(l="change attr name", p=("attrPUM"+str(i)), c=partial(zbw_mmChangeConnectAttrUI, baseObj, thisAttr, thisObj))
#create textField obj based on num, non-editable
cmds.textFieldGrp(objId, p="mmRCListLayout", w=200, ed=False, tx=thisObj)
#create pop up
cmds.popupMenu(("objPUM"+str(i)), b=3)
cmds.menuItem(l="change obj", p=("objPUM"+str(i)), c=partial(zbw_mmChangeConnectObjUI, baseObj, thisAttr, thisObj))
#create button to delete attr
cmds.button(buttonId, l="delete", w=50, c=partial(zbw_mmDeleteMsgAttr, thisAttr))
else:
cmds.text("no message attributes on this object", p="mmRCListLayout")
评论列表
文章目录