Find identical geometry and instance it
Everybody who have imported large amount of data from any cad system know that it normally kills the instancing. The intention of this script is to find geometrically identical nodes and instance them. This script will of course work if someone have used copy instead of instance in a scene and wants them instanced instead.
Added 2015:
I'm happy to see that so many have tried out my Sunday hack that I made 5 years ago...but as it was only something to do for a Sunday its not really something I support. I would love to, but my daytime job takes all my time ;-)
But the code is open so please take it and redo it....take the idea and redo from scratch or improve it (and there is a lot of possibilities to do that ;-)
The basic idea was to: Compare the geometries by looking at face order and relations between faces and disregard everything else. If they match, then instance and align the 1st face of the new instance with the object that matches, 1st face, before deleting the found object. This is to make it stay in the same position as before even if its a totally different pivot point and rotation.
To be instanced.....
The nodes needs to have:
Identical face count, same class, identical face topology and identical scale
The nodes does not need to have :
Identical Transform,Pivot point position, Materials, Parents or Children
Why:
I did not want to read a book and crosswords are boring so I thought I would make a type of script, that is far from what I do as a daytime job.
Improvement:
I have already got some hints on what to do, and I really appreciate it.
The really slow part is the compare geometry topology stuff. If the face count is big and they are very close to the same topology then it will go through all faces in both objects while comparing, and that takes time.
I have included a MAX and Collada test file for anybody that wants to test out the script or help me improve it....
Hope this can help someone in their daily work....
... and as always, don't run this before backing up your scene... ;-)
Attachment | Size |
---|---|
Find_Identical_geometry_and_instance_it_v02_r01.ms | 5.73 KB |
A testfile for the script.... MAX 2010 format | 1.88 MB |
A testfile for the script.... Collada format | 808.36 KB |
Comments
Awesome script, especially
Awesome script, especially propagating the transform of the original mesh.
Is there any way to do this calculations only on visible objects, because, for example, some of them i don't want to be instanced, and i could easily hide them.
Not only to find the same
Not only to find the same objects, but it also calculates how transformations were wearing ...
For me, this is incredibly good.
Other scripts have not found that it could.
anubis and enthed, if you
anubis and enthed, if you want to make it faster and better there are a few simple things you can do.
first off leave the worldTM out of it and multiply the positions of items (verts faces ect) by the inverse transform to get em to local space, then dont check all faces or verts if you check 42 of 3k verts for their relative position in the mesh and they match the index and position its highly likely the meshes are equal.. plus it will create a seperate reality everytime you run it .. if you got that joke grats at your memory ;)
Raphael Steves
Hi. I tried this script on
Hi. I tried this script on easy scene width 20 objects importet by 3DS format from sketchup, but script doesn't work properly. See the attachement. Your script helped me, but on this object doesn't work and i don't know where is a mistake. Thank you.
goooood script :)
goooood script :)
Thanks Jedie, I still work
Thanks Jedie, I still work with Max2009, and I glad to hear that my script is compatible with objects that even I've no seen yet :) also I appreciate your advice to merge both scripts. If Martin permit I could add his face topology checks as an option to my script.
my recent MAXScripts RSS (archive here)
The current version doesn't
The current version doesn't work with the new BodyObjects. It doesn't found identical geometry while compage the maded snapshots.
The script http://www.scriptspot.com/3ds-max/scripts/instance-identical-geometry can handle BodyObjects.
IMHO a good idea: Merge the scripts.
Thanks for the file. I
Thanks for the file. I already have an idea that work fine here, but now I can test it better on your file. Of course, as any man and I have to fight with my problems, so I can't tell when I'll done with this task (just hope will be soon).
[edit] I was done something, attached ;-)
Cheers,
Anubis
my recent MAXScripts RSS (archive here)
I have added a collada
I have added a collada file...
Unfortunately I cannot open
Unfortunately I cannot open the scene file. Recently I saw the same missing dll error and only can guess it come from files maded in Max 2010. I forgot to insert so I work on Max 2009.
my recent MAXScripts RSS (archive here)