PDA

View Full Version : detect duplicate objects' name


nico_guilty
07-03-2008, 03:56 PM
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

stefan
07-04-2008, 08:55 AM
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

martroyx
07-04-2008, 09:30 AM
obj = (for f in selection where f.name == "objname" collect f)
clearselection()
select obj

shibumenon
07-04-2008, 10:10 AM
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.

martroyx
07-04-2008, 10:22 AM
(
obj = #()
for f in selection do (appendifunique obj (getNodeByName f.name))
clearselection()
select obj
)

CGTalk Moderation
07-04-2008, 10:22 AM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.