Grasshopper

algorithmic modeling for Rhino

Hey everyone!

I'm new to VB.NET and some rather annoying error is keeping me from moving forward with my work.

Here's an example of what i'm trying to do: create a polyline by adding points generated (recursively) by one starting point; if the polyline gets close to a certain boundary (curve), it jumps it.

Simple as it looks, i keep giving an error: "script exception: the index was out of the interval. it has to be not negative and inferior to the size of the collection. Name of the parameter: index"

weird thing #1 - i have no "index" parameter in my code
weird thing #2 - the only list is created inside the script and grows at the same pace as the loop index i have ("i").

Can anyone figure this out?

Thanks!

Views: 632

Attachments:

Replies to This Discussion

Hello rvzkm,

Why are you incrementing i inside the loop? There is the line:

i = i + 1

on line #74. The for loop does this for you. If you want to increment another variable, make a separate counter. I commented this out, and the polyline jumps over the curve...

When you get this error its because you have reached a point in a list or array where your index (the index value of the element in the array or list) is outside of the size of your array or list. The way your list works, you have added "pt" in line 68...so your list has one element in it. Once you start in the for loop, you are adding other elements. The first time you go into the loop, you add a point, your list has two elements, upperbound index is 1. But then you increment the i variable, so the next time you go into the loop, line 72 is looking for list_pt(2) when you actually should just be on list_pt(1)...anyways...try it out and see if it does what you need...

Luis
So that was it?! Thanks a LOT Luis, it worked just fine ;)

I didn't know the For loop made the increments by itself - back when i programmed with fortran90 we had to do it inside!

No wonder i couldn't figure it out...

Thanks!

RSS

About

Translate

Search

Photos

  • Add Photos
  • View All

Videos

  • Add Videos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service