Nicole.09.25_Geometry.Study

Option Explicit
‘Script written by Nicole Acaron-Toro
‘Script version 09.25.2009

Call Main()
Sub Main()

 Dim arrStartPt, arrAttPt, addPoints, ctrPoint, arrCtrPoint
 Dim crvVertex, arrPts, line, crvPoints, arrCrvPoints
 Dim crvTangs, i, j, intPlane, dblTangPar, intPlanePt, intPlanePts
 
 ‘ user input – arrPts
 arrStartPt = Rhino.GetObject(“select start point”, 1) 
 arrStartPt = Rhino.PointCoordinates(arrStartPt)
 
 arrAttPt = Rhino.GetObject(“select the attractor point”, 1) 
 arrAttPt = Rhino.PointCoordinates(arrAttPt)
 
 ‘ define midpoints
 addPoints = Rhino.PointAdd(arrStartPt, arrAttPt)
 ctrPoint = Rhino.PointDivide(addPoints, 2)
 ctrPoint = Rhino.AddPoint(ctrPoint)
 arrCtrPoint = Rhino.PointCoordinates(ctrPoint)
  
 crvVertex = Rhino.MoveObject (ctrPoint, arrCtrPoint, Array(arrCtrPoint(0),arrCtrPoint(1), 20))
 crvVertex = Rhino.PointCoordinates(crvVertex)
 
 ‘ define 3 point array and insert curves 
 arrPts = Array(arrStartPt, crvVertex, arrAttPt)
 line = Rhino.AddInterpCurve(arrPts)

 ‘ subdivide curve
 Dim intPlaneDivisions(), Count, ctrPlane, ctrPt
 
 crvPoints = Rhino.DivideCurve(line, 30)
 
 For i = 0 To UBound(crvPoints)

  arrCrvPoints = Rhino.AddPoint(crvPoints(i))
  arrCrvPoints = Rhino.PointCoordinates(arrCrvPoints)
  
  dblTangPar = Rhino.CurveClosestPoint(line, arrCrvPoints)
  crvTangs = Rhino.CurveTangent(line, dblTangPar)
  
  intPlane = Rhino.PlaneFromNormal(arrCrvPoints, crvTangs)
  intPlane = Rhino.AddCircle(intPlane, 2)
  
  ‘subdivide circles
  intPlanePt = Rhino.CurveStartPoint(intPlane)
  intPlanePt = Rhino.AddPoint(intPlanePt)
  
  
 
 Next
 
 Call interpolatedHelix
 
 
End Sub

Function interpolatedHelix
 
 Dim j, intPlanePts, intPlaneDivisions(), Count, arrIntPlanes
 
 arrIntPlanes = Rhino.ObjectsByType(4)
 
 For j = 0 To UBound(arrIntPlanes)
   
  intPlanePts = Rhino.DivideCurve(arrIntPlanes(j), 4, False, True)
  ReDim Preserve intPlaneDivisions(Count)
  intPlaneDivisions(Count) = intPlanePts
  Count = Count + 1
  
 Next
  
 Dim blnPtsArray: blnPtsArray = 0
 Dim arrCrv: arrCrv = 0
 Dim helixCrv, k
 
 helixCrv = Rhino.AddCurve(Array(intPlaneDivisions(arrCrv)(blnPtsArray), intPlaneDivisions(arrCrv + 1)(blnPtsArray + 1), intPlaneDivisions(arrCrv + 2)(blnPtsArray + 2), intPlaneDivisions(arrCrv + 3)(blnPtsArray + 3), intPlaneDivisions(arrCrv + 4)(blnPtsArray), intPlaneDivisions(arrCrv + 5)(blnPtsArray + 1), intPlaneDivisions(arrCrv + 6)(blnPtsArray + 2), intPlaneDivisions(arrCrv + 7)(blnPtsArray + 3), intPlaneDivisions(arrCrv + 8)(blnPtsArray), intPlaneDivisions(arrCrv + 9)(blnPtsArray + 1), intPlaneDivisions(arrCrv + 10)(blnPtsArray + 2), intPlaneDivisions(arrCrv + 11)(blnPtsArray + 3), intPlaneDivisions(arrCrv + 12)(blnPtsArray), intPlaneDivisions(arrCrv + 13)(blnPtsArray + 1), intPlaneDivisions(arrCrv + 14)(blnPtsArray + 2), intPlaneDivisions(arrCrv + 15)(blnPtsArray + 3), intPlaneDivisions(arrCrv + 16)(blnPtsArray), intPlaneDivisions(arrCrv + 17)(blnPtsArray + 1), intPlaneDivisions(arrCrv + 18)(blnPtsArray + 2), intPlaneDivisions(arrCrv + 18)(blnPtsArray + 3), intPlaneDivisions(arrCrv + 19)(blnPtsArray), intPlaneDivisions(arrCrv + 20)(blnPtsArray + 1), intPlaneDivisions(arrCrv + 21)(blnPtsArray + 2), intPlaneDivisions(arrCrv + 22)(blnPtsArray + 3), intPlaneDivisions(arrCrv + 23)(blnPtsArray), intPlaneDivisions(arrCrv + 24)(blnPtsArray + 1), intPlaneDivisions(arrCrv + 25)(blnPtsArray + 2), intPlaneDivisions(arrCrv + 26)(blnPtsArray + 3), intPlaneDivisions(arrCrv + 27)(blnPtsArray), intPlaneDivisions(arrCrv + 28)(blnPtsArray + 1), intPlaneDivisions(arrCrv + 29)(blnPtsArray + 2), intPlaneDivisions(arrCrv + 30)(blnPtsArray + 3) ))
End Function

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