Find identical geometry and instance it

34 votes
Version 2 Revision 1
Date Updated: 
Author Name: 
Martin Enthed

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.

Additional Info: 

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

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.

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... ;-)

Version Requirement: 
MAX 2008 and later
Find_Identical_geometry_and_instance_it_v02_r01.ms5.73 KB
A testfile for the script.... MAX 2010 format1.88 MB
A testfile for the script.... Collada format808.36 KB


Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
lantlant's picture

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.

Graph's picture

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

tomastnt's picture

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.

bug.png 165.17 KB
instances.max 404 KB
instances.3DS 53.88 KB
lantlant's picture

goooood script :)

goooood script :)

Anubis's picture

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)

jedie's picture

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 can handle BodyObjects.

IMHO a good idea: Merge the scripts.

Anubis's picture

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 ;-)


AttachmentSize 1.5 KB 1.08 KB

my recent MAXScripts RSS (archive here)

enthed's picture

I have added a collada

I have added a collada file...

Anubis's picture

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.

Missing DLLs

my recent MAXScripts RSS (archive here)

enthed's picture

No problem I will look at

No problem I will look at your code for inspiration... ;-)
I have included a test file for you....

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.