Thursday, October 4, 2007

Still having a bug

Ok Sky, I removed the bug, no more error message, but when I try hiding objects, command cannot grab anything. Array after sorting is name-string array, not object-string array.

Another problem is that since SortStrings reads CurveLength number as string...
Array (32, 9,12,11, 25)
Sorted Array (11, 12, 25, 32, 9)

I guess I'll go back to my studio now...

Option Explicit

ShowCurve ()
Sub ShowCurve ()

Dim arrCurve, arrSorted, strTemp, i

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

'Assign Curves to new array and rename objects
For i = 0 To UBound(arrCurve)
If Rhino.IsCurve(arrCurve(i)) Then

strTemp = Rhino.CurveLength(arrCurve(i))
arrCurve(i) = Rhino.ObjectName (arrCurve(i), "Curve" & CStr(strTemp))
Rhino.Print (arrCurve(i))
Rhino.Sleep 300

End If

'Sort lengths in ascending order
arrSorted = Rhino.SortStrings(arrCurve, True)

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

'Show the Objects in curve length order
For i = 0 To UBound(arrSorted)

strTemp = arrSorted(i)
Rhino.ShowObject (strTemp)
Rhino.Print "sorted:" & (arrSorted(i))
Rhino.Sleep 300


End Sub