AN_Multiple Helix

Option Explicit

By Adolfo Nadal

Copyrighted by Archiologics

Call Main()
Sub Main()
 Dim i, n
 n = Rhino.GetInteger(“Nr of points”, 50,1,100)
 If IsNull (n) Then Exit Sub
 
 Dim D
 D = Rhino.GetInteger(“Diameter for curves”,2,1,5)
 
 Dim basePt : basePt = Rhino.GetPoint(“Base Point”,array(0,0,0))
 
 Dim k, h : h = Rhino.GetInteger(“Nr of Curves”, 4,1,360)
 Dim rad
 
 Dim Pt(), Pts()
 Dim arrPts (), arrPtss()
 Dim arrCrv()
 Dim PolyPt()
 Dim r
 Dim Poly
 
 Rhino.EnableRedraw(False)
 For k = 0 To h-1
  rad = k/h*2*PI
  
  For i = 0 To n-1
   
   ReDim Preserve arrPts(i)
   ‘ReDim Preserve arrPtss(i)
   arrPts(i) = Rhino.AddPoint(array(D*sin(i+rad)+basePt(0),D*cos(i+rad)+basePt(1),i+basePt(2)))
   ‘arrPtss(i) = Rhino.AddPoint(array(cos(i+rad),sin(i+rad),i))
  
   ReDim Preserve Pt(i)
   ‘ReDim Preserve Pts(i)
   Pt(i) = Rhino.PointCoordinates(arrPts(i))
   ‘Pts(i) = Rhino.PointCoordinates(arrPtss(i))
     
   If i>0 Then
    ReDim Preserve arrCrv(i)
    ‘rrCrv(i-1) = Rhino.AddLine (Pt(i),Pt(i-1))
   End If
   
   If i=n Then
    Rhino.Print(“Point ” & (i) & “: ” & (sin(i)) & “, ” & (cos(i)) & “, ” & (i))   
   End If
  
  Next
  
  Poly = Rhino.AddInterpCurve (Pt)
  r = (Rhino.CurveLength(Poly)/2000)
  Rhino.SelectObject(Poly)
  ‘Rhino.Command “Sellast enter Pipe pause 1 pause enter 1 enter enter”
  Rhino.Command “Pipe (r) enter (r) enter enter”
  Rhino.DeleteObjects(arrPts)
  Rhino.UnselectAllObjects
 Next
 Rhino.EnableRedraw(True)
 Rhino.AddText “Settings: ” & vbCrLf & “1. general radius= ” & (D) & vbCrLf & ” 2. Number of Curves: ” & (h) & vbCrLf & ” 3. Sample points: ” & (n),array(basePt(0),basePt(1)-10, basePt(2)),.5,”arial”
 ‘Rhino.AddInterpCurve Pts
 
End Sub

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s