macroScript DoomSplineResizer category:"# Scripts" tooltip:"Spline resizer script by Doomgrave" buttontext: "SplineResizer" icon:#("Splines", 1) --icon:#("Doom_Icons", 2) -- version = 0.4 /* DoomSplineResizer By Vin Carbone (doomgrave) USAGE: For best use associate the script to a Key button (es. D that is free by default) You can add a toolbar button found in "# Scripts" category Use the key or press the toolbar button to start drawing a line Repress the key/button to insert a line size or use the rollout tab Set desired lenght and press ENTER or SET button to resize the spline If you select a new line the script will take you to the resize rollout directly The spline Pivot will be centered and aligned to the first vertex of the spline Script works with any shape with a single spline, if you use a complex spline, the script will set the total lenght Enjoy precision drawing in MAX! WARNING: The script will Xform your spline! */ ( global rltSetSplinesLength try destroyDialog rltSetSplinesLength catch() if selection.count == 1 and superClassOf $ == Shape then( if $.scale == [1,1,1] then ( try local lenght = curvelength $ catch(local lenght = 10) ) else ( try local lenght = (curvelength $ * $.scale.x) catch(local lenght = 10) ) local spl = $ ) else (local lenght = 10 print "please select a shape and click SET button") rollout rltSetSplinesLength "Set Splines Length" width:150 ( spinner spnLength "Length:" range:[0.001, 10000, lenght] align:#center button btnShape "SET" width:104 align:#center -- Script opening on rltSetSplinesLength open do ( if selection.count == 1 and superClassOf $ == Shape then ( setFocus spnLength) else (startObjectCreation line) ) -- Script Button pressed on btnShape pressed do undo "Set Splines Length" on ( if selection.count == 1 and superClassOf $ == Shape then ( if spl == undefined or isDeleted spl or spl.name != $.name do ( local spl = $ resetxform spl convertToSplineShape spl local lenght = curvelength spl spnLength.value = lenght print lenght ) local spl = $ resetxform spl convertToSplineShape spl local lenght = curvelength spl local len = spnLength.value local pPoz = getKnotPoint spl 1 1 local qPoz = getKnotPoint spl 1 2 spl.pivot = pPoz toolMode.pivotCenter() toolMode.coordsys #local local scalef = len/lenght if scalef != 1 do ( scale spl [scalef,scalef,scalef] local lenght = curvelength spl resetxform spl convertToSplineShape spl ) print len -- align pivot to Tape Tape_align = tape pos:pPoz target:(targetObject pos:qPoz) spl.pivot=Tape_align.pos spl_source_pos=spl.pos local pivot_rotate_angle= inverse (Tape_align.transform.rotation) spl.rotation *= pivot_rotate_angle spl.objectoffsetrot *= pivot_rotate_angle spl.objectoffsetpos *= pivot_rotate_angle spl.pos=spl_source_pos delete Tape_align updateShape spl completeRedraw() try destroyDialog rltSetSplinesLength catch() ) else (startObjectCreation line ) ) -- Script Value change on spnLength entered do undo "Set Splines Length" on ( if selection.count == 1 and superClassOf $ == Shape then ( if spl == undefined or isDeleted spl or spl.name != $.name do ( local spl = $ resetxform spl convertToSplineShape spl local lenght = curvelength spl spnLength.value = lenght print lenght ) local spl = $ resetxform spl convertToSplineShape spl local lenght = curvelength spl local len = spnLength.value local pPoz = getKnotPoint spl 1 1 local qPoz = getKnotPoint spl 1 2 spl.pivot = pPoz toolMode.pivotCenter() toolMode.coordsys #local local scalef = len/lenght if scalef != 1 do ( scale spl [scalef,scalef,scalef] local lenght = curvelength spl resetxform spl convertToSplineShape spl ) print len -- align pivot to Tape Tape_align = tape pos:pPoz target:(targetObject pos:qPoz) spl.pivot=Tape_align.pos spl_source_pos=spl.pos local pivot_rotate_angle= inverse (Tape_align.transform.rotation) spl.rotation *= pivot_rotate_angle spl.objectoffsetrot *= pivot_rotate_angle spl.objectoffsetpos *= pivot_rotate_angle spl.pos=spl_source_pos delete Tape_align updateShape spl completeRedraw() setFocus spnLength if scalef == 1 do try (destroyDialog rltSetSplinesLength) catch() ) else (print "please select a shape") ) ) resol = getMaxWindowSize() createDialog rltSetSplinesLength pos:[resol[1]/18,resol[2]/8] )