algorithmic modeling for Rhino
Hi Guys, I am trying to so something super simple. I have a list of 3dpoints input into my VB script and I want to join them into a polyline. The points are sorted already, so they won't intersect and should join fine.
I thought this problem is as simple as one or two line, but it always gives me errors. Here's the code:
Private Sub RunScript(ByVal pts As List(Of Point3d), ByRef A As Object)
Dim hex As Polyline(pts)
End Sub
the error msg is: array bounds cannot appear in type specifiers. What does this mean? And anyone has the solution to this problem?
Thanks a lot for all of your help!
Tags:
Hi Fan,
VB uses the same kind of bracket for arrays and function calls. I've always found this one of the stupidest features of the language. The way you declare your variable:
Dim hex As Polyline(pts)
is interpreted by VB as "I'll create an array of Polylines, stored in a variable called 'hex' which contains pts polylines". It complains because you're not supposed to set a definite size when you declare an array like this.
What you wanted to do though is create a NEW polyline which connects a bunch of points. If you insert the New keyword, this code will work:
Dim hex As New Polyline(pts)
Now, the brackets mean something else. The New keyword means you're calling a Constructor of the Polyline class now. A Constructor is a special function that gets called only once and always immediately when an instance of a class is first created. So in this case the brackets indicate a function call.
--
David Rutten
david@mcneel.com
Poprad, Slovakia
Welcome to
Grasshopper
© 2025 Created by Scott Davidson.
Powered by