Notifications
Clear all

[Closed] detect duplicate objects' name

Hello,
I’m looking for creating a simple script to check if there is any duplicate name in a object selection.
Or an other way to do this but I didn’t found anything yet.

I don’t think it will be difficult.
My idea is to put my selection into an array like

objs = selection as array

then to create a loop to check if the first object name in the array equal other name in it too. so if there any duplicate, print them in the listener or in a file.txt

But I’m very new in maxscript and I’m not sure of the syntax to do it.

Is there somebody to help me?

Thank you

4 Replies

This will select objects with unique names. ( if U have two $box01 objects it will select only one.)

Sel= selection as array
 nam=for obj in Sel collect obj.name
 makeUniqueArray nam
 SelB= for obj in nam collect (getnodebyname obj)
 select SelB

obj = (for f in selection where f.name == "objname" collect f)
clearselection()
select obj 

I had written a simple script long back which does what you want (print onto listener) :

http://www.aaachooo.com/maxscripts_01.html

You can go thro the script and make changes to get it working with selected objects.


(
obj = #()
for f in selection do (appendifunique obj (getNodeByName f.name))
clearselection()
select obj
)