[Closed] scripted snaps ?
hello, I was wondering if it would be possible to create scripted snaps. Can you get to the existing snap functionality?
the one i have in mind would be best described as ‘distance from endpoint’. so you would enter a distance, and then it would snap to that distance on the selected edge from it’s endpoint. great for cutting a given distance from an edge, for instance when creating a ‘smoothed bevel’
anyone?
i’ve found that through the viewport you can get a 3D location of a screen point and what not, but nothing to directly acces and modify the edge and vertex ID’s / location of that on which you snap.
Are you saying you would there to be maxscript functionality in which subobject parts like edges and vertices could be snapped to or indicated as being scrolled over like during a mouse tool use? Like they way it automatically does when you are in a subobject mode for each subobject respectively? Or if you have the snap tool on?
like when you have the snap tool on. The easiest way would be to modify the enpoint snap, but if i can code the snap and user feedback manually that would be ok too.
Edge detection is a very tricky subject by itself. I sorted it out (somewhat) for my CleanCut script, but I see a bit of a hurdle in getting from there to where you want to go. Here’s what I did, roughly, for the edge detection routine (for what it’s worth):
-
Create a mesh snapshot of the EPoly object (assuming that’s what you’re operating on), since the next step won’t work on EPoly.
-
Use mapScreenToWorldRay() and intersectRayEx() to find out what face (triangle) on the mesh is under the mouse.
-
By comparing vertices, find out which polygon on the EPoly contains the mesh triangle.
-
Loop through the poly’s edges and use the intersection point from intersectRayEx(), the edge’s vert positions, the dot product and some other math wizardry to find out which edge is closest to the mouse.
Step 4 is obviously the tricky part. Somewhere in my function for doing this I also derived a distance along the edge as a percentage (0.0 to 1.0). There may be a way to use that to find a corresponding world-unit distance. I don’t really know at this point:shrug:
If I haven’t thoroughly confused you, then there’s hope!
RH