Duplicate object finder/selecter..........
Is is possible to make a script that can find two identical objects in the same position but select only 1 of them?
I have 3000 trees to place and used replace in max to position a box at every location a tree should be. The only problem being that i started with a CAD drawing from an architect and they have duplicated the tree markers on top of each other so every location has two markers so the replace script has placed two boxes at every point.
So I'd like to select all 6000 of my boxes and run a script that would find the duplicates and select or deselect one copy at every location so I can easily delete the duplicates.
I hope that makes sense! I guess it could utilise the pivot point coordinates or something to gauge duplicates??
It would save me doing them one by one!
Here's hoping there is a genius amongst you clever people!
Cheers.
Comments
polycount check
Hej guys
there is a variable on the top checksamepoly, it has to be set to true in order to also test that those objects at the same location have the same polycount or not.
Thanks losbellos, worked
Thanks losbellos, worked perfectly!
at least 3-4 X faster, counts lot when dealing w many objects
t1 = timestamp()
selarray = selection as array
objpos = #()
theindexarray=#()
for i=1 to selarray.count do (
objpos[i] = selarray[i].pos
)
objpos2 =objpos
objpos2 = makeUniqueArray objpos2
if objpos2.count != objpos.count then (
thenewsel =#()
theposarray =#()
for i=1 to selarray.count do (
for k=i+1 to selarray.count do (
if objpos[i] == objpos[k] do (
if (finditem theposarray objpos[i]) == 0 and (finditem thenewsel selarray[i]) == 0 do (
append thenewsel selarray[i]
append theposarray objpos[i]
)
if (finditem theposarray objpos[i]) != 0 and (finditem thenewsel selarray[i]) == 0 do (
append thenewsel selarray[i]
)
)
)
)
t2 = timestamp()
print ("sorting duplicates took " + ((t2-t1)/1000.0) as string + " milisecs")
clearselection()
select thenewsel
) else (
messagebox "there are no duplicates or nthlicates xD"
)
Hi Losbellos, cool script and
Hi Losbellos,
cool script and very fast compared to other scripts i tried so far.
I tried this on a heavy scene but unfortunately the script also selects objects, which aren`t
"real" duplicates. Is it possible to add some code to also check and compare the polycount for the founded duplicates....so it is sure that these are real duplicates ?
Thanks for your help.
Robin
updated
updated
different z position objects
Hi losbellos,
is it possible to make a little change in this script?
I need to select objects that have the same position in x and y axis, but they have different z position.
Thank you.
Stefan
Thanx works for me
nice and clean boss...
just select all objects and run this.. whollah
Thank you
AJs
Try makeUniqueArray function
Try makeUniqueArray function (it's available in Max 2008 and higher)
my recent MAXScripts RSS (archive here)
Thank you Anubis! :)
Thank you Anubis! :)