Introduction to Maya - Modeling Fundamentals Vol 1
This course will look at the fundamentals of modeling in Maya with an emphasis on creating good topology. We'll look at what makes a good model in Maya and why objects are modeled in the way they are.
# 1 27-07-2018 , 01:02 PM
Registered User
Join Date: Sep 2011
Posts: 109

Automatically rename objects and their children

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.

Attached Images
File Type: jpg Rename children.jpg (71.2 KB, 3 views)
# 2 30-07-2018 , 11:19 AM
Registered User
Join Date: Sep 2011
Posts: 109
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)

Attached Files
File Type: zip Unity_LOD.zip (489 Bytes, 1 views)

Last edited by lauris47; 30-07-2018 at 11:22 AM.
Posting Rules Forum Rules
You may not post new threads | You may not post replies | You may not post attachments | You may not edit your posts | BB code is On | Smilies are On | [IMG] code is On | HTML code is Off