[Closed] How to get the middle position of edges
This sounds very simple to begin with but isn’t so simple to do quick or so it seems.
I have any kind of selection, they could be faces, borders/edges etc. And I want to know the middle point of the all the edges of these selections.
With faces it’s simple since I just convert it to faces and use GetFaceCenter, and with verts GetVert.
So, lets say I have a 100 edges selected and I want to know their middle point. One way I can imagine to do this is to remember the edges and convert them each one at a time into the 2 vertices that create the edge and then calculate the middle position by using (verta.pos-vertb.pos)/2 (well not exactly but almost).
But this sounds hideously ineffective, these kind of loops and the convertion would take far too long to be any fun.
(What I want to do: A tool that places objects at the edges of your poly object. i can now place at vertices and faces)
/Andreas
Im not sure but may be you can get the transform axis of your selection, check this:
getTransformAxis $ 0
I checked more about the axis. Just want to say:. It works! Unfortunately edges in polyOp lacks so many things (like in splineOp).If you use #selectionCenter The loca axis in SO level is always at the center of selection.COOL!!!
Hello,
I just test, don’t know if it’s exact or possible in maxscript or…
I select faces > I detach as clone > I select Pivot, center to Object. And is position is probably what you want. After you can detete the object, or undo…
Is it a good idea ?
If I understand the original question correctly, Andreas would like to find the center of each edge individually, not collectively.
RH
Ok, I read a line on 10… Sorry
But perharps this technique can be faster by using it on each polygon. Don’t know. Perharps f97ao need to do a benchmark
Yea, the collective position is nice too, but for this particular case I needed for each face, as I had planned to scatter things on the object.
/Andreas
Hi,
May be that can help you ,
Mauricio B. Gehling was make a script for insert a vertex at middle of edge ,
select an edge or several edges and run script , each edges they are splited exactly at the middle , he find the middle like that :
for x = 1 to $.selectededges.count do (
num = $.selectededges[x].index
$.insertvertexinedge num 0.5)
hey man,
if I got you correct, I would write this way: (correct me if I am wrong, then tell me what steps you want the script to perform for you)
(
local totalPos = 0
for i in (polyOp.getEdgeSelection selection[1]) do
(
local edgeVerts = polyOp.getEdgeVerts selection[1] i
local midPoint = (((polyOp.getVert selection[1] edgeVerts[1]) + (polyOp.getVert selection[1] edgeVerts[1])) / 2)
totalPos += midPoint
)
local averagePosition = totalPos / (polyOp.getEdgeSelection selection[1]).numberSet
)