distrubte vertices evenly on an edgeloop


#1

hello

I recall a very cool tool called “zentools” that could do that… but I don’t know If there is any other tool in inside Maya may to distribute vertices along an edgeloop.

using Maya 2016

thank you in advance


#2

please guide me if you can.
very appreciated.


#3

Hello,

Can you elaborate what exactly you want? A picture would help too.


#4

like this:


#5

Try “Edit Edge Flow”.
I took a plane and moved some edges around in a loop then selected “Continuous Edges”.
Then hit “Edit Edge Flow” and it snapped those edges back into alignment.
The only thing is on my plane the edge loops beside the messed up edge loop were normal so I don’t know if will work for you but simple enough to try.


#6

edit edgeflow does not help here…
why not use the zentools…?


#7

nope Edit Edge flow doesn’t work as expected…

zenTools was great… unfortunately It is for older versions of maya, in Maya 2016 and 2015 It gives errors.

I contacted the developer, he promised me an update… but sadly he is not available anymore.

I don’t know any equivalent script to do that.


#8

nevermind…


#9

any help would be great! :slight_smile:


#10

Well, I’ve been meaning to make this script. So here you go.

Run on selected mesh components
redistributeVertex(ch=False)


def redistributeVertex(ch=False):
    ''' redistribute vertex based on a uniform curve '''
    selection = cmds.ls(sl=True, fl=True)
    orgSel = selection
    verts = cmds.polyListComponentConversion(selection,
        fromFace=True,fromEdge=True,fromVertex=True,
        toVertex=True, internal=False)
    verts = cmds.ls(verts, fl=True)
    # convert to edge so we can use polyToCurve to fix vert order issues
    edges = cmds.polyListComponentConversion(selection,
        fromFace=True,fromEdge=True,fromVertex=True,
        toEdge=True, internal=True)

    vertData = {}
    positions = []
    for ii, vert in enumerate(verts):
        pos = cmds.xform(vert, q=True, ws=True, t=True)
        positions.append(pos)
        data = {'vertex':vert,'vertexPos':pos,'cv':None,'cvPos':None}
        vertData[ii] = data

    #create Curve
    cmds.select(edges, r=True)
    curve = cmds.polyToCurve( form=2, degree=1)[0]

    #find the matching cv
    cvList = []
    cvs = cmds.getAttr('{}.cv[li]'.format(curve))
[/li]    for i in range(len(cvs)):
        curveCV = '{}.cv[{}]'.format(curve,i)
        cvList.append(curveCV)
        cvPos = cmds.xform(curveCV, q=True, ws=True, t=True)
        for vert, data in vertData.items():
            vertex = vertData[vert]['vertex']
            pos = cmds.xform(vertex, q=True, ws=True, t=True)
            roundCvPos = [round(x, 3) for x in cvPos]
            roundPos = [round(x, 3) for x in pos]
            if roundCvPos == roundPos:
                vertData[vert]['cv'] = curveCV
                continue

    cmds.rebuildCurve(
            curve, ch=1, rpo=1, rt=0, end=1, kr=0, kcp=0, kep=1, kt=0, s=0, d=1, tol=0.01)
    #set New vertex postion
    for vert, data in vertData.items():
        vertex = vertData[vert]['vertex']
        curveCV = vertData[vert]['cv']
        if curveCV:
            cvPos = cmds.xform(curveCV, q=True, ws=True, t=True)
            vertData[vert]['cvPos'] = cvPos
            cmds.xform(vertex, ws=True, t=cvPos)
        else:
            print "No matchign Cv found for vertex",  vertex
    if not ch:
        cmds.delete(curve)
    if orgSel:
        cmds.select(orgSel, r=True)
    return vertData


#11

Castius that script is doing nothing here…
is there a special trick…?


#12

Thanks, man! Works great )) It’s exactly what I was looking for.


#13

oglu does that script still not work for you?


#14

still nothing… i have no clue…


#15

Yeah for some reason it’s not working for me either. But in my case I am sure I am doing something wrong.


#16

It seems two spaces slipped in your code.

change this:

data = {'vertex':vert,'vertexPos':pos,'cv':None,'cvPos':N  one}

to:

data = {'vertex':vert,'vertexPos':pos,'cv':None,'cvPos':None}

Now it should work :slight_smile:

Edit:
Okay, for whatever reason the spaces get inserted automatically. :smiley:
There shouldn’t be any between “N” and “one”.

Great script by the way!


#17

wow that is odd. why is the forum inserting an space.

Good find and thanks


#18

WOW!
For some reason doesnt work the zenTools in MaYa 2017 SP5 on this computer.

BUT…
Im looking for a script like this (I guess)
But unfortunately the script doesnt do nothing at all.

I selected 3 Vertex and run the python script.
Nothing happens.
I also select the whole Vertex loop that I need to adjust and nothing happens.

By selecting edges doesnt work either.

Can some body help me?
What Im doing wrong?

Im using MaYa 2017 SP5
Thank you in advance!


#19

With the “ZhCG_Polytools” script you have the command “average line”
(don’t pay attention to the custom menu, it’s the same command)


#20

I dont have that option directly in the submenu like you, but is over the main menu.
I tried all the option that offers and I think we are speaking to a different approach.

If you tried to un-organize your vertex Like the pic below you will never have a perfect arranged vertices like the pic below.

Vertices properly arranged .