macroScript SplineTool category:"Keffer Tools" tooltip:"SplineTool" buttontext:"Spline" ( global OriginalSplineArray = #(), NewSplineArray = #(), SplineArray = #() rollout Interpolate "Interpolate Spline" ( Group "SHAPE Info" ( spinner TLength "Total Length" range:[0,100000,0] type:#float align:#right enabled:false spinner Tsplines "Total Splines" range:[0,100000,0] type:#integer align:#right enabled:false button shapeinfo "get SHAPE info" width:120 height:20 ) Group "SPLINE Info" ( spinner SplineID "Spline #" range:[1,100000,1] type:#integer align:#right spinner TVerts "Total Verts" range:[3,100000,0] type:#integer align:#right spinner LSegment "Seg Length" range:[0,100000,0] type:#float align:#right button changespline "change selected" width:120 height:20 button getspline "get SPLINE info" width:120 height:20 ) Group "Settings" ( radiobuttons inttype "Interpolation Type" labels:#("even","path") default:2 button first "make first" height:16 across:2 button reversedir "reverse" height:16 --button revert "revert" width:120 height:20 radiobuttons vertTicks "Vertex Ticks" labels:#("on","off") default:1 ) --------------------------------------------------------------------------------- --------------------------------------------------------------------------------- on vertTicks changed state do ( case vertticks.state of ( 1: $.vertexTicks = on 2: $.vertexTicks = off ) ) ---------------------------------------------------------------------------------- on shapeinfo pressed do ( if $ != undefined do ( max modify mode subobjectLevel = 3 OriginalSplineArray = #() TSplines.value = NumSplines $ TLength.value = (curveLength $ SplineID.value) Tverts.value = numknots $ SplineID.value LSegment.value = (TLength.value / (Tverts.value - 1)) for osa = 1 to (numknots $ 1) do ( append OriginalSplineArray (getKnotPoint $ 1 osa) --stores original spline in array ) ) )--end on splineinfo ---------------------------------------------------------- on getspline pressed do ( if $ != undefined do ( subobjectLevel = 3 x = (getsplineselection $)[1] print x SplineID.value = x OriginalSplineArray = #() TLength.value = (curveLength $ SplineID.value) Tverts.value = numknots $ SplineID.value LSegment.value = (TLength.value / (Tverts.value - 1)) for osa = 1 to (numknots $ 1) do ( append OriginalSplineArray (getKnotPoint $ 1 osa) --stores original spline in array ) ) )--end on splineinfo ---------------------------------------------------------- on Lsegment entered do ( TVerts.value = (TLength.value / LSegment.value) if SplineID.value <= TSplines.value then ( NewSplineArray = #() percent = 1 / (Tverts.value - 1) as float selectedspline = (getsplineselection $)[1] SplineID.value = selectedspline for nsa = 0 to (Tverts.value - 1) do --stores new verts ( if inttype.state == 1 then ( --append NewSplineArray (lengthinterp $ SplineID.value (percent * nsa)) append NewSplineArray (lengthinterp $ selectedspline (percent * nsa)) ) else ( --append NewSplineArray (pathinterp $ SplineID.value (percent * nsa)) append NewSplineArray (pathinterp $ selectedspline (percent * nsa)) ) ) for del = (numknots $ SplineID.value) to 1 by -1 do -- deletes old verts ( deleteKnot $ SplineID.value del ) for i = 1 to Tverts.value do --adds new verts ( --addknot $ SplineID.value #smooth #curve (NewsplineArray[i]) addknot $ SplineID.value #corner (NewsplineArray[i]) ) updateshape $ --LSegment.value = (TLength.value / (Tverts.value - 1)) ) else ( TLength.value = 0 Tverts.value = 0 LSegment.value = 0 ) ) ---------------------------------------------------------- on TVerts entered do ( LSegment.value = (TLength.value / TVerts.value) if SplineID.value <= TSplines.value then ( NewSplineArray = #() percent = 1 / (Tverts.value - 1) as float selectedspline = (getsplineselection $)[1] SplineID.value = selectedspline for nsa = 0 to (Tverts.value - 1) do --stores new verts ( if inttype.state == 1 then ( --append NewSplineArray (lengthinterp $ SplineID.value (percent * nsa)) append NewSplineArray (lengthinterp $ selectedspline (percent * nsa)) ) else ( --append NewSplineArray (pathinterp $ SplineID.value (percent * nsa)) append NewSplineArray (pathinterp $ selectedspline (percent * nsa)) ) ) for del = (numknots $ SplineID.value) to 1 by -1 do -- deletes old verts ( deleteKnot $ SplineID.value del ) for i = 1 to Tverts.value do --adds new verts ( --addknot $ SplineID.value #smooth #curve (NewsplineArray[i]) ) updateshape $ LSegment.value = (TLength.value / (Tverts.value - 1)) ) else ( TLength.value = 0 Tverts.value = 0 LSegment.value = 0 ) ) ---------------------------------------------------------- on changespline pressed do ( LSegment.value = (TLength.value / TVerts.value) if SplineID.value <= TSplines.value then ( NewSplineArray = #() percent = 1 / (Tverts.value - 1) as float selectedspline = (getsplineselection $)[1] SplineID.value = selectedspline for nsa = 0 to (Tverts.value - 1) do --stores new verts ( if inttype.state == 1 then ( --append NewSplineArray (lengthinterp $ SplineID.value (percent * nsa)) append NewSplineArray (lengthinterp $ selectedspline (percent * nsa)) ) else ( --append NewSplineArray (pathinterp $ SplineID.value (percent * nsa)) append NewSplineArray (pathinterp $ selectedspline (percent * nsa)) ) ) for del = (numknots $ SplineID.value) to 1 by -1 do -- deletes old verts ( deleteKnot $ SplineID.value del ) for i = 1 to Tverts.value do --adds new verts ( --addknot $ SplineID.value #smooth #curve (NewsplineArray[i]) ) updateshape $ LSegment.value = (TLength.value / (Tverts.value - 1)) ) else ( TLength.value = 0 Tverts.value = 0 LSegment.value = 0 ) ) ---------------------------------------------------------- on change pressed do ( if SplineID.value <= TSplines.value then ( NewSplineArray = #() percent = 1 / (Tverts.value - 1) as float for nsa = 0 to (Tverts.value - 1) do --stores new verts ( append NewSplineArray (lengthinterp $ SplineID.value (percent * nsa)) ) for del = (numknots $ SplineID.value) to 1 by -1 do -- deletes old verts ( deleteKnot $ SplineID.value del ) for i = 1 to Tverts.value do --adds new verts ( --addknot $ SplineID.value #smooth #curve (NewsplineArray[i]) ) updateshape $ LSegment.value = (TLength.value / (Tverts.value - 1)) ) else ( TLength.value = 0 Tverts.value = 0 LSegment.value = 0 ) ) ----------------------------------------------------------- on splineID changed value do ( if SplineID.value <= TSplines.value then ( subobjectLevel = 3 setsplineselection $ #(splineID.value) OriginalSplineArray = #() TSplines.value = NumSplines $ TLength.value = curveLength $ SplineID.value Tverts.value = numknots $ SplineID.value LSegment.value = (TLength.value / (Tverts.value - 1)) for osa = 1 to (numknots $ SplineID.value) do ( append OriginalSplineArray (getKnotPoint $ SplineID.value osa) --stores original spline in array ) ) else ( TLength.value = 0 Tverts.value = 0 LSegment.value = 0 ) ) ----------------------------------------------------------- on first pressed do ( setfirstspline $ (getsplineselection $)[1] updateshape $ setsplineselection $ #(1) ) ----------------------------------------------------------- on reversedir pressed do ( reverse $ (getsplineselection $)[1] updateshape $ ) ----------------------------------------------------------- on revert pressed do ( if SplineID.value <= TSplines.value then ( for del = (numknots $ SplineID.value) to 1 by -1 do -- deletes old verts ( deleteKnot $ SplineID.value del ) for i = 1 to OriginalSplineArray.count do ( --addknot $ splineID.value #smooth #curve (OriginalSplineArray[i]) ) updateshape $ ) else ( TLength.value = 0 Tverts.value = 0 LSegment.value = 0 ) ) --------------------------------------------------------------- ) SplineTools = newRolloutFloater "Spline Tools" 160 420 AddRollout Interpolate SplineTools )