Monday, January 1, 2007

DivideCurve ( ) _yuki

Here is my first script I wrote from scratch. User can pick two curves, divide into the number s/he wants, and draw lines accordingly. Array was complicated, but I'm getting hang of it.

Option Explicit
'S.S.S.S. sciarcsmac first challenge #2

Sub DivideCurve()
Dim strFirstCurve
strFirstCurve = Rhino.GetObject("Select the first curve", 4)
If IsNull(strFirstCurve) Then Exit Sub

Dim strSecondCurve
strSecondCurve = Rhino.GetObject("Select the second curve", 4)
If IsNull(strSecondCurve) Then Exit Sub

Dim t
t = Rhino.GetInteger("Number of division?", 10, 2, 100)
If IsNull (t) Then Exit Sub

Dim arrFirstCurvePoints
arrFirstCurvePoints = Rhino.DivideCurve(strFirstCurve, t, True)

Dim arrSecoudCurvePoints
arrSecoudCurvePoints = Rhino.DivideCurve(strSecondCurve, t, True)

Dim strAddedLines
Dim i

For i = 0 To t Step 1
strAddedLines = Rhino.AddLine(arrFirstCurvePoints(i), arrSecoudCurvePoints(i))


Dim strSayYes
strSayYes = Rhino.GetString ("Continue? ", "Y")
If Not strSayYes = "Y" Then Exit Sub

Rhino.Print "Well done! "

End Sub