Find identical geometry and instance it

34 votes
Version: 
Version 2 Revision 1
Date Updated: 
02/27/2010
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

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

Version Requirement: 
MAX 2008 and later
AttachmentSize
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

Comments

Comment viewing options

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

In my code (it's just an

In my code (it's just an quick example) show how I'll struct logical the code (to can extend it with more comparing options), and yes, that topology check on each face I found as slow. I see your point to go on this way, I just think so there must to be some more faster way... Sorry so dubd your script ;) Don't worry, you done good script, am just a mxs maniac (lol). I'll post another script that also will not sort your issue with CADs objects but may will bring to you some ideas :) [edit] It's here: http://www.scriptspot.com/3ds-max/scripts/select-similar-objects

[edit 2] ...if you attach a small example max scene file (with few imported CAD objects) just to test on it, I'll check it out later on to see if I can find something.

cheers,
Anubis

my recent MAXScripts RSS (archive here)

enthed's picture

Yes, I saw your script

Yes, I saw your script "Anubis" but it really don't solve the problem I was after, if you are not hiding that in something I can't see of course. That is if you have imported geometry from a CAD system, you normally get several nodes that should be instances but have different orientation and different transforms.

1st, I have tried to take care of that, so even if they have different transforms and pivot points according to the geometries direction it will solve the instancing. I use their first face transform of the both objects to translate the instanced node to the right place.

2nd, Even if the face count is the same you can't be certain that the models are the same so I try to do a topology check on each face, maybe not the fastest one, but still it's there ;-). I can't see that in your script.

Your script looks more professional than mine so you could probably redo my script with above features if you want too !!! ;-) If you do I would love to see it.....

/Martin

Anubis's picture

Its very hard workaround

Its very hard workaround coding to achieve the goal ;-)

[EDIT] I wrote something from scratch right now:
http://www.scriptspot.com/3ds-max/scripts/instance-identical-geometry

I hope it helps.

Best regards,
Anubis

my recent MAXScripts RSS (archive here)

satori's picture

Cool man, always wanted

Cool man, always wanted something like this!
Thanks!!

Comment viewing options

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