ScriptSpot home

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

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

Reply to miauu
David_Lee

Sorry, I did a mistake. It works properly!

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

Branko Živković

try this


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

Reply to Branko Živković
David_Lee

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

Reply to David_Lee
Branko Živković

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