zbw_clash.py 文件源码

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

项目:zTools 作者: zethwillie 项目源码 文件源码
def nameFix(name):
    """
    for xforms - this will take a base name (ie.'pCube') and find all instances of that and rename by appending a
    number, starting with the deepest instances in the DAG hier, so as not to bollocks up the later searches by
    changing items on top of obj
    """
    mayaObjs = cmds.ls(name)
    print "---------\nI'm in nameFix for: {0}, and there are --{1}-- instances of this clash".format(name,
                                                                                                     len(mayaObjs))
    mayaObjs.sort(key=lambda a: a.count("|"), reverse=True)  # this sorts by greatest number of "|"

    if mayaObjs:
        if len(mayaObjs) > 1:
            for x in range(0, len(mayaObjs) - 1):
                cmds.rename(mayaObjs[x], "{0}_{1}".format(mayaObjs[x].rpartition("|")[2], x))
                print "zbw_clash.nameFix: Changed name of {0} --> {1}".format(mayaObjs[x], "{0}_{1}".format(
                    mayaObjs[x].rpartition("|")[2], x))
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号