Grasshopper

algorithmic modeling for Rhino

I have 2 2-dim arrays that I want to combine such that array A elements get placed into the even indices of the new array and array B elements get placed into the odd elements.

I thought this would be easy - outline of code.

x=0

j=0

k=0

For i=0 to (A.count()+B.Count()-2)

  if (xmod2)=0 then

      arrNew(i) = A(j)

      j=j+1

  else

      arrNew(i) = B(k)

      k=k+1

  endif

Next

 

But I can't seem to get a count of the number of elements in the first dimension of the array(The getLength() vb.net method doesn't seem to be implemented and I can't even seem to access a particular element such as A(0)(1) which seems to suggest that the data I am getting from grasshopper is not acting like a 2-dim array.

Any help would be appreciated. thanks.

Views: 407

Replies to This Discussion

Try right clicking on "x"/ "y" and "flattening" both. This will pass in 1 1-d array in each x and y.Then you can sort out the lists however you would like.

Grasshopper is a series of 1-d array's. Conceptually it does not have a 2-d array. That is the innovative part about branches and trees. It throws of traditional programmers, but becomes very intuitive. I am sure there are a lot of people that can expand on this better then I can.

Hope this helps.

John,

Thanks for the suggestion. I will definitely give it a try. Do you know of other ways of doing this that I am not thinking of? I find it hard to believe that any time someone reads into a script component what I am thinking of as a multidimensional array ,but should probably think of as a tree, they have to flatten it and rebuild it into a real multidimensional array.

Like I said I really appreciate the help just want to make sure I understand the full picture.

Thanks again.

RSS

About

Translate

Search

Videos

  • Add Videos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service