09.28.Helix.Al.Crvs_Nicole

Option Explicit

‘Script written by Nicole Acaron-Toro

 

Call Main()

Sub Main()

 

                   Dim arrAttPts, arrStartPts, i, extLines, addPoints, ctrPoints, arrCtrPoints, crvVertex, j, distPoints, arrPts, line, points

                   

                    ‘ user input – attractors, objects

                    arrStartPts = Rhino.GetObjects(“select start points”, 1)

                   

                    For i = 0 To UBound(arrStartPts)

                                        arrStartPts(i) = Rhino.PointCoordinates(arrStartPts(i))

                                        arrAttPts = Rhino.GetObjects(“select the attractor points”, 1)

                                                           

                                        For j = 0 To UBound(arrAttPts)

                                                            arrAttPts(j) = Rhino.PointCoordinates(arrAttPts(j))

                                                            ‘extLines = Rhino.AddLine (arrStartPt, arrAttPts(i))

                                       

                                                            addPoints = Rhino.PointAdd(arrStartPts(i), arrAttPts(j))

                                                            distPoints = Rhino.Distance(arrStartPts(i), arrAttPts(j))

                                                            ctrPoints = Rhino.PointDivide(addPoints, 2)

                                                            ctrPoints = Rhino.AddPoint(ctrPoints)

                                                            arrCtrPoints = Rhino.PointCoordinates(ctrPoints)

                                       

                                                            crvVertex = Rhino.MoveObject (ctrPoints, arrCtrPoints, Array(arrCtrPoints(0),arrCtrPoints(1),(distPoints*0.5)^2))

                                                            crvVertex = Rhino.PointCoordinates(crvVertex)

                                       

                                                            arrPts = Array(arrStartPts(i), crvVertex, arrAttPts(j))

                                                            line = Rhino.AddInterpCurve(arrPts)

                                                           

                                                            Call curveDiv(line)

                                                            Rhino.DeleteObject line                                                           

                                        Next

                    Next

                   

                    points = Rhino.ObjectsByType(1)

                    Rhino.DeleteObjects points

End Sub

 

Function curveDiv(line)

 

                    Dim crvPoints, arrCrvPoints, dblTangPar, crvTangs, intPlane, intPlanePt, i, arrIntPlanes, j

                   

                    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, 0.2)

                   

                                        intPlanePt = Rhino.CurveStartPoint(intPlane)

                                        intPlanePt = Rhino.AddPoint(intPlanePt)                                                                        

                    Next

                                       

                    Call interpolatedHelix(arrIntPlanes)

                                       

End Function

 

Function interpolatedHelix(arrIntPlanes)

                   

                    Dim j, intPlanePts, intPlaneDivisions(), Count

                   

                    arrIntPlanes = Rhino.ObjectsByType(4)

                    ‘ user input                    

                    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, arrCrv: arrCrv = 0, 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) ))

 

                    For k = 0 To UBound(arrIntPlanes)

                                        If Rhino.IsCircle(arrIntPlanes(k)) Then

                                                            Rhino.DeleteObject arrIntPlanes(k)

                                        End If

                    Next

                   

End Function

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 )

Google+ photo

You are commenting using your Google+ 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 )

Connecting to %s