Grasshopper

algorithmic modeling for Rhino

Hi,

I build in a vb component an array of doubles with 115 rows and 3 columns, as an output. I need to reuse this array as an input in another vb component. My problem is that the input array is a simple list of 345 doubles, and not an array with 115 rows and 3 columns anymore, as if I used the flatten option, which is not the case. I declared the input array as a list of doubles. Is it possible to preserve the input array with the same dimensions ?

Views: 353

Replies to This Discussion

The reason this happens is because Array implements IEnumerable. When you output some instance that implements this interface I foreach over the data and collect all stuff inside of it into a single lists. This is why it becomes 'flattened'.

A way to trick the Grasshopper type detector into wrapping your multi-dimensional array would be to put it into an array, i.e.

A = New Object() {array}

where array is a multi-dimensional array of some type.

A somewhat neater way would be to supply your data as Grasshopper data, so the type detector doesn't even come into play, this would look like:

A = New GH_ObjectWrapper(array)

--

David Rutten

david@mcneel.com

Poprad, Slovakia

Thanks David,

I tried the second method you described and it works perfectly.

For other people interested :

In my first vb component, I define my output array with B = New GH_ObjectWrapper(tabElts), where tabElts is my array of Doubles.

In the second vb component, I set the input as an Item Access, type System.Object.

Then I can use my input array with the correct dimensions (115 rows and 3 columns in my case).

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