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
Thanks for sharing this! Works well.
I have the same need as you described with repurposing CAD data. This works well! Kudos to you!Thank you!
Improvement
For a more predictable result, which instance will be taken as a basis, I suggest taking the last object from the selection.
Improvement
Not always instances are oriented correctly. What if to check not the angle between the normals of the faces and the distance between the centers of the faces, but to compare the positions of the corresponding points in the space of the first face? Have you tried this method?
Objects are moved from its places
Hello,I apply this script to this model I attach it her, before applying the script i reset Xform for All geometry but when i apply it some of geometry are moved from it place and some are rotated, and i wish if you can tell me how to solve this problem, thanks in advance.
https://www.dropbox.com/s/fih1sadfv2j5qti/light-part.max?dl=0
Multi core possibility ???
Hey,first thanks a lot for this script,I'm interested to develop this script to be multi core script to be able make a huge calculation in short time , there is any possibility ????
Thanks in advance.
1 create box (box 01) 2
1 create box (box 01)
2 making a copy of boxing (box 02)
3 convert mesh (box 02)
4 convert poly (box 02)
5 convert poly box 01
6 Findidentical run and did not find out the identity of the script
and we fix it?
is messed up, it Improves the
7 convert mesh (box 02)
8 convert poly (box 02)
9.Findidentical run and find the identity of the script
I do not know why.
It really is a bug.
Is there a way to specify
Is there a way to specify what object will be the reference one? Eventually with a name suffix, like _master ?
I saw that the object with the starting vertices is taken as reference.
I have a question, how does
I have a question, how does the script detect what object it takes as a reference?
Because i've encountered an issue when i've cloned a bunch of cylinders, and gave them different transforms + resetxform, but kept one "straight".
The script didn't take the straight one as a reference, but a rotated one, and broke the original one rotation.
I've attached a max file for example. There, Tube_01 is the straight one but the script takes Tube_00 as being the reference one.
In fact, Tube_00 was the first created.
Me and I needed a version
Me and I needed a version that has a ProgressBar:
https://dl.dropboxusercontent.com/u/1587713/script/Find_Identical_geomet...
(the only difference is the progressbar in the original script)
of course
headd!
of course,
only one word to replace :)
This script will only work on the selected objects.
https://dl.dropboxusercontent.com/u/1587713/script/Find_Identical_geomet...