View Full Version : Delete duplicated objects help needed!
06-16-2008, 09:45 AM
Hi there people,
I got a acad file with the position of loads of trees. now i want to replace the acad objects with tree models.
Looking at the acad file in max i have removed all block.style objects.
But that i saw every object has three objects below it (so if i select one i get three obejcts selected) this means there are some duplicated objects.
i thought i could write a script that goes thrue all the objects. then checks if there are objects with the same position and delete them
i cannot get something to work and i really need this.
I hope some1 has an idea on how to do this.
Many thanks in advance!
06-16-2008, 11:31 AM
Some weeks ago I bought from Autodesk an e-DVD called 'A day in the life of a TD', where Bobo explains some tools and workflows he developed at Frantic. And there's one script that does exactly what you are looking for. If you can afford it, I think it's a good way to go.
Hope it helps!
06-16-2008, 12:17 PM
thanks for that pointer m8, but that would help me much. i only have 3 days for this project left and i kinda need it fast.
search continues.... :)
06-16-2008, 12:48 PM
if you just want to try positions, it would be something along the lines of...
-- get all the objects in an array
objs = objects as array
-- get the number of objects
objsCount = objs.count
-- create an array that will hold all duplicates of given objects
dupeSets = for i = 1 to objsCount collect ( #() )
-- loop over all objects, with 'i' being used for the object to check against
for i = 1 to objsCount do (
-- and 'j' being used for the object currently being checked
for j = (i+1) to objsCount do (
-- check how close they are. If they are within 0.001 units
if (distance objs[i] objs[j] < 0.001) then (
-- then append the 'j' object to the duplicates set of the 'i' object
append dupeSets[i] objs[j]
Once run, you'll have an array of arrays, the inner array being the duplicate sets. You can then parse that however you want. For example, to print them out to an understandable list:
for i = 1 to objsCount where (dupeSets[i].count > 0) do (
dupeNames = for o in dupeSets[i] collect ( o.name )
format "% -> %\n" objs[i].name dupeNames
GeoSphere01 -> #("GeoSphere03", "GeoSphere05")
GeoSphere02 -> #("GeoSphere04")
GeoSphere03 -> #("GeoSphere05")
Meaning that GeoSphere01 has two dupes: GeoSphere03 and GeoSphere05. GeoSphere02 has one dupe: GeoSphere04. GeoSphere03 has one dupe, GeoSphere05.
You might wonder why GeoSphere05 isn't culled from the GeoSphere03 list, seeing as that was already listed in GeoSphere01's dupes. The reason is simple.. Imagine GeoSphere01 being in the center, GeoSphere03 to its left and GeoSphere05 to its right. In that situation, GeoSphere03 and GeoSphere05 may be close enough to GeoSphere01 to be considered dupes, but not close enough to eachother to be considered dupes. So the above tells you that GeoSphere03 and GeoSphere05 are likely to be dupes of eachother as well.
Using similar code, you can select all considered-dupe objects:
for dupeSet in dupeSets do ( selectMore dupeSet )
I should warn you, though, that this only checks for objects' positions (by pivot point). You may also want to check if the objects have, say,the same number of vertices / faces, so that you don't end up deleting objects that are in the same position, but completely different geometry. E.g. if you have a house at [0,0,0] and in the center of that house is a table that is also positioned at [0,0,0], then given just a positional check, they would be considered duplicate.
06-16-2008, 12:48 PM
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.
vBulletin v3.0.5, Copyright ©2000-2014, Jelsoft Enterprises Ltd.