Aug 2007
1 / 8
Aug 2007
Aug 2007

as shown in image;I need to select nearest face of polygon and snap to other object
snap together tool works as how I want.

but how can I automate via mel that operation
I know nearest face have to be selected and snaptogether tool will be exeuted.

I want just select two objects and they will snap same as gif picture shows .

maybe multiple objects and a surface to be snap together operation via mel
because its hard to focus-find bottom face-select other nearest object face point manually.
I want to automate that via mel...I think I will do.
but any help will be appricated and shorten develop time lost.

any clue ?

thanks before, for helps.

  • created

    Aug '07
  • last reply

    Aug '07
  • 7

    replies

  • 4.3k

    views

  • 1

    user

  • 2

    links

Hmm Yeah I have come up with varius solutions for this.. one way you coud go ..

You could have the script duplicate the face and seperate it.. then center the pivot on the object and then you could use a parent constraint with maintain offset turned off to snap the object to that face.. then delete the extraneous face.

My first thought was use xform to get the worldspace space of the face but it returns the coords of all the vertices that make up the face.. I suppose it wouldn't be too hard to do soem math to get the center of the face from that and then move the object to the point in space.

Another method I have used is to select two edges , duplicate edges to curves, then make a nurbs loft between the two curves, then make a curve on surface, then attach the object to the path.. but it's alot of stuff to do and is slow if you have alot of these happening and coudl probably be solved with fewer steps and a geometry constraint etc nowadays.

Okay revising question again:

Its possible to find nearest face's and points for both objects... that not too be so hard.
but then I need something like that

snaptoGetherTool(<34,43,23>,<134,43,80>)

a given two world point coordinates as a parameter to the tool function.

I am pointing this.
how a snap together tool function can be written ?

or already there is a function for this that I am missing.

thanks

there is nearestPointOnMesh.mll (/closestPointOnMesh.mll) with that you can look for the ... well the name just said it ;]

Maybe look for the closest point on the ground from the object, then from that point to the object.
Now the hardest part: Get the surface normals and turn stuff so that it fits.
that way you wouldn't need coordinates as well.
I mean you want to use that non interactively, don't you?

@gmask! Whoooow! That sounds like a bunch of nasty hacks but stuff works. of course.
How come you post so much recently? never seen you that active.

QUOTE
Another method I have used is to select two edges , duplicate edges to curves, then make a nurbs loft between the two curves, then make a curve on surface, then attach the object to the path.. but it's alot of stuff to do and is slow if you have alot of these happening and coudl probably be solved with fewer steps and a geometry constraint etc nowadays.

Also known as the rivet trick!

Do you want to drop stuff on ground? or do you want them to converge to nearest point? which is quite different. Anyway if you know the closet point on one of the meshes to the other you can just do this.

make a closest point on mesh node connect the simpler more complex node t it. then try the center of your second opject as point. note the vector, cull all faces to that vector. then search remeining vertices. OR as a algorithm that may or may not converge swap mesh and ask last solution point to the new mesh swap again and do this a few times.

Then store normals at those points rotate about the second opbjects point with:

http://www.fundza.com/mel/axis\_to\_vector/a...\_to\_vector.html49

except instead of y you use your normal!