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))
评论列表
文章目录