ScriptSpot

Forum topic · General Scripting

Check for double names and rename them

By David_Lee · 2013-05-21

Description

I'm looking a way to check if there are objects with the same name and rename them to make all objects in scene with a unique name.

Any idea?

Comments (5)

miauu · 2013-05-21

The code works properly. It renames the Speres properly and I have 001,002,004,005,006. You can attach the scene.

David_Lee · 2013-05-21

Sorry, I did a mistake. It works properly!

I forgot to delete a row in my script before run it.

try this

barigazy · 2013-05-21


objNames = #()
for o in objects do
(
if findItem objNames o.name == 0 then append objNames o.name else
(
newname = o.name = uniquename o.name ; append objNames newname
)
)
free objNames

David_Lee · 2013-05-21

Thanks barigazy...but it doesn't work as expected

I have these objects in scene:

Sphere001
Sphere002
Sphere002
Sphere003
Sphere004

Your code rename the second Sphere002 to Sphere003... and I have now two Sphere003 in scene

barigazy · 2013-05-21

When I run the code on your example you 3rd sphere "Sphere002" becomes "Sphere005"