Grasshopper

algorithmic modeling for Rhino

Hi there,

 

I have an old code written in the legacy VB.net format and i am trying to translate it to the new VB.net. In my attempt I always bump into this error

"error: Index was out of range. Must be non-negative and less than the size of the collection.Parameter name: index (line: 0)"

 

I understand that this means there is something wrong with my data lists. I feed the same data to both scripts. The legacy one operates smoothly, but the new doesn't. has anybody been through a similar case?

 

Regards,

M

Views: 594

Replies to This Discussion

Hi Marios,

 

without seeing any code I won't be able to give any support.

 

--

David Rutten

david@mcneel.com

Poprad, Slovakia

Yeah David I know,

That makes sense, I wanted to, but unfortunately I can't share it at the moment cause it is a commercial project. This error is usually a data list length error isn't it?

 

Thanks in advance,

M. 

Typically yes, you're trying to access an element in a collection, list or array that is outside of the bounds.

 

The odd thing is the error happens at line 0. Does this error happen after you compile the script or is it something that happens while the script runs?

 

--

David Rutten

david@mcneel.com

Poprad, Slovakia

This might be understandable: the line refers to the highest frame in the stack, and this frame is the .Net one (it is in mscorlib.dll, in System.Collections.Generic.List.Item(index) I would say), not the one in Grasshopper.dll. This is probably why the runtime cannot solve the line number.

- Giulio

_______________

giulio@mcneel.com
McNeel Europe

Thank you Giulio,

 

I will try and re-write the code from scratch in the new VB.net and not just translate it. That might solve give me some hints. I will post back if I make some progress.

Thank you for you help.

M.

Sorry David,

For some reason I missed that answer of yours. No, it happens when I compile it. As I said to Giulio I think I will write the whole script from scratch in case i am missing something. thanks for your help. if i manage to find what is going on I will let you know

 

M.

Here is something strange.

I have just decided to give the code another try. I transferred the component in a 'fresh' file and it works!!! Without changing a single bit of the code. ......weird.....And I was so frustrated that I began a whole discussion on the matter. Pfff.

Anyway thanks to everyone for their help. I will try my components in new files first in the future..

 

M. 

This is very strange. Scripts inside components get compiled from scratch whenever a solution is run and the script isn't compiled yet. It could either be in an uncompiled state because the ghx file was only just opened, or because someone specifically destroyed the compiled code (as I do when you close the Code Editor window).

 

Copy/Pasting a component into a different file will obviously result in a recompile, but then so should opening the same file again.

 

What happens when you paste the component back into the original file?

 

--

David Rutten

david@mcneel.com

Poprad, Slovakia

Copying at the first file to the same file doesn't work. Copying from the new file  to the first is ok.. I have no idea what is wrong...

M.

RSS

About

Translate

Search

Videos

  • Add Videos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service