Rename objects according to parent's name

Rename objects according to parent's name

lauris4747
Contributor Contributor
2,556 Views
2 Replies
Message 1 of 3

Rename objects according to parent's name

lauris4747
Contributor
Contributor

Hi,

maybe someone could help me to rename selected objects and their children.

I want to export many objects using FBX to Unity. Unity recognises LOD (Level of detail) according to the naming.

Each LOD should be within the original model.

 

I have around 2000 objects, some of them have 2 children, some of them have 1.

The naming should be according to parent's name + _LOD + depth. Lets say parent is Object1 so the naming should be:

Object1_LOD0 - Parent object

   Object1_LOD1 - First child object 

      Object1_LOD2- Second child object 

 

 Object2_LOD0

    Object2_LOD1

 

 Object3_LOD0

    Object3_LOD1

          Object3_LOD2

etc...

 

I hope someone can help. Thank you.

 

Rename children.jpg

 

 

0 Likes
Accepted solutions (1)
2,557 Views
2 Replies
Replies (2)
Message 2 of 3

viru.gupta8
Enthusiast
Enthusiast
Accepted solution

# select your all parent object or get list of them. allParentObjects = cmds.ls(sl=True) for object in allParentObjects: dag_obj = cmds.listRelatives(object, ad=True, type="transform") #gives you all child objects objectsToRename = [object]+dag_obj #list parent then child for num, obj in enumerate(objectsToRename): cmds.rename(obj, obj+"_LOD"+str(num))

I think That will do your Job.

0 Likes
Message 3 of 3

lauris4747
Contributor
Contributor

Thank you very much!

0 Likes