def add_zero_one_attribute(attrType, *args):
"""
adds an attribute with range of 0 to 1 to each selected obj
:param attrType: either "short" or "float"
:param args:
:return:
"""
sel = cmds.ls(sl=True)
if not sel:
cmds.warning("You need to select an object add attrs to!")
return()
attrName = cmds.textFieldGrp(widgets["newAttrTFG"], q=True, tx=True)
if not attrName:
cmds.warning("Please enter a name for the attribute in the field!")
return()
for obj in sel:
try:
cmds.addAttr(obj, ln=attrName, at=attrType, min=0, max=1, dv=0, k=True)
except:
cmds.warning("Couldn't add attr: {0} to object: {1}. Skipping.".format(attrName, obj))
评论列表
文章目录