Tuesday, October 2, 2007

Show Curves in Order of Length

For some reason I can't debug this code. Has problems with sortnumber variable type. Can anyone figure this out?

Option Explicit

ShowCurve ()

Sub ShowCurve ()

Dim arrCurve, i, arr(), temp, arr2()

'Get The Curves
arrCurve = Rhino.GetObjects ("select a curves to evaluate", 4)

'Assign Curves to new array and rename objects
For i = 0 To UBound(arrCurve)
If Rhino.IsCurve(arrCurve(i)) Then
temp = Rhino.CurveLength(arrCurve(i))
Rhino.Print (temp)
ReDim Preserve arr(i)
arr(i) = temp
Rhino.ObjectName arrCurve(i), "Curve" & CStr(temp)
End If

'Sort lengths in ascending order
arr2 = Rhino.SortNumbers(arr, vbTrue)

'Hide all Objects
Rhino.Command ("SelAll")
Rhino.Command ("Hide")

'Show the Objects in curve length order
For i = 0 To UBound(arr2)
Temp = CStr(arr2(i))
Rhino.ShowObject "Curve" & Temp
Rhino.Sleep 1000

End Sub