Automatically rename objects and their children
1 Attachment(s)
Hi, I have an issue,
I have 2000 objects and some of them have children. At max each object has two more children. At minimum, objects has one child. Could someone help in renaming them with Mel or Python? I want them named for example: Object1_LOD0 Object1_LOD1 Object1_LOD2 Object2_LOD0 Object2_LOD1 etc. Thank you. |
1 Attachment(s)
My wonderful colleague created this script in Python for me. It does exactly what I have described above.
I have attached it. import maya.cmds as mc import os def rename_lod(path, name, n): if "LOD" in name: name = name[:-5] print "Renaming", path, "to", name rels = mc.listRelatives(path, children=True, fullPath=True) print rels if len(rels) == 1: mc.rename(path, name+'_LOD'+str(n)) return elif len(rels) > 2: print "Too many children in one layer" os.exit(1) else: child = rels[1] rename_lod(child, name, n+1) mc.rename(path, name+'_LOD'+str(n)) sel=mc.ls(selection=True) for each in sel: try: name = each.split('|')[1] except: name = each rename_lod(each, name, 0) |
All times are GMT. The time now is 05:51 PM. |
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Simply Maya 2018