zbw_attributes.py 文件源码

python
阅读 24 收藏 0 点赞 0 评论 0

项目:zTools 作者: zethwillie 项目源码 文件源码
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))
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号