def zbw_mmConnectM(*args):
"""
uses the items from the textFields to create message attrs in the base obj, and connects to those the objs from the rightmost fields of the UI
"""
#check there's a base obj
if (cmds.textFieldButtonGrp("zbw_tfbg_baseObj", q=True, tx=True)):
#check there are any fields created
if (cmds.rowColumnLayout("mmRCLayout", q=True, ca=True)):
children = cmds.rowColumnLayout("mmRCLayout", q=True, ca=True)
numObj = (len(children)/2)
if numObj:
for num in range(1, numObj+1):
attrTFG = "attr" + str(num)
objTFBG = "obj" + str(num)
baseObj = cmds.textFieldButtonGrp("zbw_tfbg_baseObj", q=True, tx=True)
targetObj = cmds.textFieldButtonGrp(objTFBG, q=True, tx=True)
baseAttr = cmds.textFieldGrp(attrTFG, q=True, tx=True)
baseMAttr = baseObj + "." + baseAttr
objMAttr = targetObj + ".message"
#check to make sure there's something in each field, otherwise skip
if baseAttr and targetObj:
#check that attr doesnt' already exist with connection
if (cmds.attributeQuery(baseAttr, n=baseObj, ex=True)):
#delete the attr that exists, print note about it
cmds.deleteAttr(baseMAttr)
cmds.warning(baseMAttr + " already exists! Deleting for overwrite and reconnection")
cmds.addAttr(baseObj, at="message", ln=baseAttr)
cmds.connectAttr(objMAttr, baseMAttr, f=True)
#print confirmation of connection
print("Connected: "+ objMAttr +"--->"+ baseMAttr)
else:
cmds.warning("Line # " + str(num) + " was empty! Skipped that attr")
#leave a text field saying that it's done
zbw_mmDeleteConfirm()
cmds.separator("mmConfirmSep", h=20, st="single", p="mmAddNewConnections")
cmds.text("mmTextConfirm", l="MESSAGES MAPPED!", p="mmAddNewConnections")
else:
cmds.warning("Please create some attrs and objs to connect to base obj!")
else:
cmds.warning("Please choose a base object to add attrs to!")
评论列表
文章目录