Home Technical Talk

Maya: Unify Edge Length ?

Dawsky
polycounter lvl 9
Offline / Send Message
Dawsky polycounter lvl 9
Hi all. 

I was wondering if there was a way to unify the length of all selected edges in the screenshot in maya 2018.
Maybe there is a script capable of doing that? Google didnt tell me much. 



Replies

  • Dawsky
    Offline / Send Message
    Dawsky polycounter lvl 9
    Ok, in case someone needs this working in the future, here is what i did:

    get a reference length.

    def getEdgeLengthFunc (*pArgs):
        global referenceLength
        referenceLength =[]
        sel1=cmds.ls(sl=True,fl=True)
        cmds.ConvertSelectionToVertices()
        p=cmds.xform(sel1,q=True,t=True,ws=True)
        referenceLength=math.sqrt(math.pow(p[0]-p[3],2)+math.pow(p[1]-p[4],2)+math.pow(p[2]-p[5],2))
        cmds.select(sel1)
        cmds.selectMode(co=True)
        cmds.selectType(eg=True)
        print 'Reference Length=',referenceLength

    apply that length to a selected edge. only works on single edge.

    def setEdgeLengthFunc (*pArgs):
        sel2=cmds.ls(sl=True,fl=True)
        cmds.ConvertSelectionToVertices()
        p=cmds.xform(sel2,q=True,t=True,ws=True)
        initialLength=math.sqrt(math.pow(p[0]-p[3],2)+math.pow(p[1]-p[4],2)+math.pow(p[2]-p[5],2))
        cmds.select(sel2)
        cmds.selectMode(co=True)
        cmds.selectType(eg=True)
        lengthToSet=abs(referenceLength / initialLength)
        
        cmds.scale( 1, lengthToSet, 1, cs=True, a=True)

    This code maybe very poor written as i have no idea what i am doing :) So i dont take responsibilities when something goes wrong.
Sign In or Register to comment.