# Scale Edges To Specific Lengths ?

 03 March 2018 DavidFalke   portfolio 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: http://forums.cgsociety.org/archive...p?t-846300.html) and one to set the length to the value that i get from the first function. 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 def setLengthFunc (*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( 0.0, lengthToSet, 0.0, cs=True ) What am i missing here ?  Last edited by DavidFalke : 03 March 2018 at 05:20 PM. share quote
 03 March 2018 DavidFalke   portfolio 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. share quote

 Posting Rules You may not post new threads You may not post replies You may not post attachments You may not edit your posts vB code is On Smilies are On [IMG] code is On HTML code is Off CGSociety Society of Digital Artists www.cgsociety.org Powered by vBulletinCopyright ©2000 - 2006, Jelsoft Enterprises Ltd.
Forum Jump
 Please select one User Control Panel Private Messages Subscriptions Who's Online Search Forums Forums Home -------------------- Gallery     Latest Entries     Featured 2D     Featured 3D     CG Awards     Community Awards Main     News     General Discussion     Off Topic     Recruitment         Temp Job Board Challenges     CGS Environment 101     Education     Demo Reel     Portfolio Review GROUPS WIP ADVICE     CGS Pro     New 2D/3D Sketchbooks 2018     WIP 2D/3D & Animation         WIP/Critique: 3D         WIP/Critique: 2D             Speedpaints & Sketchbooks         WIP/Critique: Animation     Partners and Groups         Art Direction and Interviews         Kitbash 3D Thunderdome         Collaborative Projects Autodesk     Autodesk Maya         Maya Dynamics         Maya Rendering         Maya Character Setup         Maya Programming     Autodesk Miscellaneous         Autodesk MotionBuilder         Autodesk Mudbox         Autodesk Softimage             XSI: Programming             ICE: Interactive Creative Environment     Autodesk 3ds max         3dsMax Tutorials & Tips         3dsMax Resources         3dsMax SDK and MaxScript         Plugins & Add-ons         Particle Flow     Mudbox Featured Gallery ZBrush     Featured Zbrush Gallery     Pixologic ZBrush     Keyshot     Marvelous Designer Texturing     Allegorithmic Substance         Substance Designer         Substance Painter         Substance Featured Gallery     Texturing XYZ     Mari     Marmoset Toolbag Software     Maxon Cinema 4D         Cinema 4D Resources     Side Effects Houdini     Compositing Software         The Foundry Nuke         Adobe After Effects         Autodesk Effects and Compositing         Eyeon Software Digital Fusion     Additional Software         Lightwave 3D             LW Resources             LW Tutorials         The Foundry Modo             The Foundry Time Travel Challenge         E-on Software Vue         Photoshop / Painter         Blender         3DCoat Techniques     Art Techniques and Theories     Digital Matte Painting         Digital Matte Painting Mini-Challenge     Modeling         Modeling Challenge             Member Model Collection     Texturing and Surfacing     Character Rigging     Animation     Lighting and Shaders         Lighting Challenges     Compositing and Editing     Anatomy and Figurative Art         SPOTLIGHT: Best of the Artistic Anatomy and Figurative Art Forum         Tutorials and Workshops         Personal Anatomy & Sketchbook Threads         References, Resources, and Supplies Technical     VR/AR     Master Virtual Reality with BrioVR     Workstation Builds     Game Engine     Graphics Programming     Technical and Hardware     Support and Reported Post
Miscellaneous

All times are GMT. The time now is 02:37 AM.