Grasshopper

algorithmic modeling for Rhino

Hi,

  I am getting a hair-pulling error using the VB.NET scripting module.  Basically, I am trying to write a script that recursively applies a function onto a list until all of that lists elements are used up.  One of the global variables I created is a new list ("Dim haystack As New List(Of Curve)), but when I try to populat that list using the AddRange method...I get this weird error!  I was hoping someone might have insight; images and gh file attached.

Views: 280

Replies to This Discussion

Attachments:

I haven't tried your code. But in general, if you are going iterate through a collection (list) and remove elements, you should be stepping though the list in descending order.

For example:

For i as Integer = haystack.Count - 1 to 0 Step -1

' TODO...

Next

 

 -- Dale

Thanks for pointing that out!  I fixed it, but I'm still getting that error.  It occurs at the second line of code:

"haystack.AddRange(surf)"

When I comment that out, it disappears.  Any idea why it might be happening?  It doesn't seem to be because haystack is defined below the sub...not sure what else could cause it.

Could it have something to do with the fact that the VBScript module can only declare global static variables?

RSS

About

Translate

Search

Photos

  • Add Photos
  • View All

Videos

  • Add Videos
  • View All

© 2022   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service