AddPolyline VBscript V5

#1

This is a stupid simple question but I haven’t touched VBScript in so long I’m a bit lost. I’m trying to simply feed Rhino.AddPolyline known points. Trying to simply pass an array of arrays of coordinates to AddPolyline fails with an “array required” error. How do I format the input array to get it to work? Below is an example of a polyline I’m trying to draw.

arrClearance(0) = Array(3.25, 0, 0)
arrClearance(1) = Array(3.25, 0, -21.833858)
arrClearance(2) = Array(6.35, 0, -25.4)
0 Likes

#2

Hi Jim,
That looks right as far as creating the points and adding them to the polyline array goes… Is arrClearance declared/dimensioned as a fixed-length array?

dim arrClearance(n)

If you don’t know the number of points before you start, then you need to use a dynamic array…

0 Likes

#3

It is…huh. This is a more complete sample that’s not working for me. I used VarType to check that everything is in fact an array, it seems to say so?

Bah, got it, the array had to be declared with a length of “2” instead of 3, even though I could swear what I looked up counterintuitively said otherwise.

Dim strClearanceCrv
Dim arrClearance(3)
arrClearance(0) = Array(3.25, 0, 0)
arrClearance(1) = Array(3.25, 0, -21.833858)
arrClearance(2) = Array(6.35, 0, -25.4)
strClearanceCrv = Rhino.AddPolyline(arrClearance)
0 Likes

#4

Yep, in VB the “length” is always the highest index (starting at 0) whereas in Python the length is the actual number of slots.

0 Likes