Sunday, December 31, 2006

Solution #1 (Sky)

I hope everyone's gotten started on your scripts. Here's my take on Challenge #1. Instead of starting with a panel I started with two curves. The user gets to input how many panels they want from 2 to 500 with the default value set at 10. To make this I used the tutorials along with the searching the method helpfiles. Working out the bugs with the nested arrays took a while. My original intent was to work in 2d and make ellipses that would span the two points on the curves with varying thickness. In the end I couldn't think of any other way than Rhino.command and that was giving me trouble.








































Here's the script:

Option Explicit

Call Main()

Sub Main
Dim t
Dim strCurve1, strCurve2
Dim arrCurve1Points(), arrCurve2Points()

t = Rhino.GetInteger("Number of Divisions",10,2,500)

Do
strCurve1 = Rhino.GetObject("Select First Curve",4)
If IsCurve(strCurve1) Then Exit Do
Loop

Do
strCurve2 = Rhino.GetObject("Select Second Curve", 4)
If IsCurve(strCurve2) Then Exit Do
Loop

Call AddPoints(strCurve1, t, arrCurve1Points)
Call AddPoints(strCurve2, t, arrCurve2Points)

Dim r
Dim arrTemp

For r = 0 To t-1 'line30
arrTemp = Array(arrCurve1Points(r), arrCurve1Points(r+1), arrCurve2Points(r+1), arrCurve2Points(r))
Call Rhino.AddSrfPt(arrTemp)
'Call Rhino.AddLine(arrCurve1Points(r), arrCurve2Points(r))
Next

End Sub

'This function makes an array of points on the selected curve
Function AddPoints(StrCurve, t, ByRef CurvePoints)

Dim arrDomain, dblParam, arrPoint

arrDomain = Rhino.CurveDomain(StrCurve)
dblParam = arrDomain(1)/t

Dim i
For i = 0 To t
arrPoint = Rhino.EvaluateCurve(StrCurve, dblParam * i)
ReDim Preserve CurvePoints(i)
CurvePoints(i) = arrPoint
'Call Rhino.AddPoint (arrPoint)
Next

End Function