Check for double names and rename them

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

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
miauu's picture

The code works properly. It

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

David_Lee's picture

Sorry...

Sorry, I did a mistake. It works properly!

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

barigazy's picture

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 

bga

David_Lee's picture

Thanks barigazy...but it

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's picture

When I run the code on your

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

bga

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.