Option Explicit 'Script written by 'Script copyrighted by 'Script version Saturday, September 27, 2008 11:10:10 AM Call Main() Sub Main() 'declare variables, prefix with type for clarity Dim dblVar, dblHscale, dblVscale, intSize, dblCurv, dblRad,intQuant Dim strCurv, arrPoints(), arrptNext, dblAng, arrptBase, dblAdd, dblStep 'these variables are pretty standard in every script so they dont need prefixes '(i skip the letter "l" because it looks too much like the number 1) Dim i,j,k,m, x,y,z 'get user-specified data intSize=Rhino.GetInteger("size",10) intQuant=Rhino.GetInteger("quantity",20) dblCurv=rhino.GetReal("curvature",5) 'specify constants, these could be user specified too dblHscale=5 dblVscale=3 'set the counter to its initial position m=1 'step through user-specified quantity For i=0 To intQuant 're-set spiral components arrptBase=Array(0,0,0) dblAng=(i*(360/intQuant)) dblRad=10*dblHscale 'start bulge factor @ halfway up tower. it will decrease by one 'each count,moving from positive To negative dblAdd=(intSize/2) 'set sharpness of curve to a random ammount dblStep=RandomNumber((dblCurv/2), (2*dblCurv)) If m=1 Then m=-1 Else m=1 End If 'step through user-specified height For j=0 To intSize 'increase height increment arrptBase(2)=j*10*dblVscale 'rhino.AddPoint arrptBase 'increase angle increment dblAng= (dblAng + (2*m*dblStep)) 'increase (or decrease) radius by bulge factor dblAdd=dblAdd-1 dblRad=dblRad+dblAdd 'redim the point array to include the next point '(redim means to change the 'dimension' (or size) of an array) ReDim Preserve arrPoints(j) arrPoints(j) = Rhino.Polar(arrptBase, dblAng, dblRad ) arrPoints(j)(0) = arrPoints(j)(0)*2 'delete the previous curve (only if there is one) If j>1 Then Rhino.DeleteObject strCurv End If 'add the new curve. strCurv=Rhino.AddInterpCurve(arrPoints) Next 'run the pipe function on the final curve then delete it PipeOne strCurv, 1 Rhino.DeleteObject strCurv Next End Sub Function RandomNumber(nMin, nMax) RandomNumber = Null If Not IsNumeric(nMin) Then Exit Function If Not IsNumeric(nMax) Then Exit Function If nMin >= nMax Then Exit Function Randomize RandomNumber = ((nMax - nMin + 1) * Rnd + nMin) End Function Sub PipeOne(strRail, pipeRadius) Dim strCmd rhino.SelectObject strRail 'Pipe the curve using rhino's command string format strCmd = "! _Pipe _Enter" & pipeRadius & " _Enter" & pipeRadius & " _Enter _Enter _Enter" Rhino.Command strCmd End Sub