Notifications
Clear all

[Closed] Instance tool

Hi,
I need to find 3 linearly independent vector, all starting at the same point from one of the vertexes of a mesh and pointing at other 3 vertexes of the same mesh.
I’m trying to write a function that when given a certain object, will find the indexes of 4 vertexes that will define a vector space. The output of this function should look like this:
#(pivot vertex, vertex for X, vertex for Y, vertex for Z)
I also need this function not to be too complex because it is going to be called many times.

My first attempt at this was simple, I picked 3 vertexes from one face to make sure they are not on the same line and than looked for a 4th vertex that is not on the same plane with the other 3. I used the length of the projection of the 4th vertex on the plane defined by the 3 for that. This method worked most of the time but I’m trying to do better.

So my second attempt was to pick 4 corners of the bounding box of the object and find the closest vertexes to them. This approach is better, but still not ideal.

I would like to find a way to find the best combination of vectors possible or at list a good one. I am going to use this function in a script that looks for potential instances in a scene and matches them by instancing their base objects and compensating on their differences by transforming one of them to match the other.

Any ideas?

10 Replies
 lo1

Interesting idea and thanks for sharing!

Great tool for modeling. Thanks Matan!


-- Error occurred during fileIn in <...\InstanceTool.mse>
-- Error occurred in anonymous codeblock; filename: ...\InstanceTool.mse; position: 4196; line: 11
>> MAXScript FileIn Exception: -- Compile error: Undeclared variable:  sp <<

4 Replies
(@matanh)
Joined: 2 years ago

Posts: 0

OOpps, sorry about that… I have uploaded a fixed version, could you test and let me know if it works for you now?
Cheers.

(@denist)
Joined: 2 years ago

Posts: 0

i have the same error…

(@matanh)
Joined: 2 years ago

Posts: 0

Now it should be really fixed

(@denist)
Joined: 2 years ago

Posts: 0

well it works now.

May I give you some advice?
You can analyze the geometry (topology) on trimesh level. Doing this you can group:

  1. any geometry class objects
  2. objects with a transform applied
  3. xref objects (with is extremely helpful)
  4. objects with modifiers applied (make references)…

Also attach method for many objects might be faster. There is a discussion on this forum about this matter.

why is it encrypted? is it the real treasure or … kinda… displaying modesty?

thanks for posting the tool anyway. it helped me to fix 4-5 years old bug in some of my tools.

Denis, you are right, I shouldn’t have posted this thread here, I will post a new thread in the main 3dsmax forum so that users can enjoy the script (hope this time it will be in the right forum, it’s just that I only look at this forum so it was natural for me to post here but it isn’t the place of encrypted code as you said…). My mistake.
Cheers,
Matan.