Scale Edges To Specific Lengths ?


Hi everyone.

I am looking for a way, to scale one or preferably multiple edges of an object to a specific length or in other words: Unify their length.
I have a number of edges on an object, each with unique position and rotation, that need to be the same length.
It seems there is no built in option so scripting seems to be the best bet.
I was looking into python already, but my knowledge is pretty much non existing, let alone MEL so i had little success.
I was able to scale an edge by but not to a certain value and couldnt get it to work the other way around.

Here is what i did, which may or may not be complete nonsens as i have no clue what i am doing:
I built 2 functions. One to get the length of an edge (credit belongs here:
and one to set the length to the value that i get from the first function.

def getEdgeLengthFunc (*pArgs):
global referenceLength
referenceLength =[],fl=True)
print ‘Reference Length=’,referenceLength

def setLengthFunc (*pArgs):,fl=True)
lengthToSet=abs(referenceLength - initialLength)
cmds.scale( 0.0, lengthToSet, 0.0, cs=True )

What am i missing here ?


Ok, in case someone needs this working in the future, here is what messed up my code.
swap “lengthToSet=abs(referenceLength - initialLength)” for “lengthToSet=abs(referenceLength / initialLength)

… and it works.


This is a very handy script… Thank you for sharing!
I would like to extend its properties by adding for each in selection. Lets say, I saved an edge length and now I need to transfer that information to all the selected in a group. Currently, the script treats all selected edges as one.
This is what I have:,fl=True)
for each in selection:
p = cmds.xform(selection, 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))
lengthToSet = abs(referenceLength / initialLength)
cmds.scale(1, lengthToSet, 1, cs=True, a=True)
Any idea how to treat each selected edge as its own?