Grasshopper

algorithmic modeling for Rhino

Very urgent!!!!the problem of index out of range

how to solve the this problem when the warning is inside the component?

"1. Solution exception: Index was out of range. Must be non-negative and less than the size of the collection. Parameter name: index"


how to solve the " Index was out of range"?
could you give e the answer?

1. Solution exception:Index was out of range. Must be non-negative and less than the size of the collection.Parameter name: index

Views: 10080

Replies to This Discussion

if you have a list with 5 items and you try to pick the sixth one = index out of range

first item has index 0 if you try to pick item at index -1 = index out of range

And in case that you work via code this all times classic (and a "bit" barbaric) approach always works:

List<Point3d> pList = new List<Point3d>(){p1,p2,p3,p4,p5,p6};

for(int i = 0, i<pList.Count;i++){

   Point3d pCurrent = pList[i];

   Point3d pNext;

    try{pNext = pList[i+1];} catch{pNext = pList[0];} // meaning the obvious, he he

   Line line = new Line(pCurrent, pNext);

   ... blah, blah ...

}

could you send me the step?
because i have never learnt the script and VB

how to use this script?

is this code suitable for all case?

NO this was just the simplest possible  demo of using the try/catch way.

Since you are unfamiliar with coding > FORGET it

Er... solving something without that something is rather silly.

Moral: POST your definition (including data in Rhino file or internalized)

could you upload your vb component?
but i dont know why many fails happen here.

could you teach me please???

thank you!
tomorrow is my deadline!

Rutten added a function to wrap a number within a size.

Private Sub RunScript(ByVal list As List(Of Object), ByVal index As Integer, ByRef A As Object)

Dim wI As Integer = GH_MathUtil.WrapInteger(index, list.count)
A = list(wI)
End Sub

Attachments:

thanks ...now i go to try it first

but i want to ask what is that meaning of y input and x input inside this script?

RSS

About

Translate

Search

Videos

  • Add Videos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service