Grasshopper

algorithmic modeling for Rhino

Hi guys,

My plan is simple, I have data in a file that is arranged the following way(example): 

1 2 3 4

5 6 7 8

9 10 11 12

I already extracted those data, now I want to put them in a tree so that the output will show a tree with 3 branches of 4 integers each that I can pass on to other components. What is the best way to do it?

I have tried creating a tree and using a for loop to do so, but it didn't work. 

Thank you for your help. 

Views: 3374

Replies to This Discussion

Get these 2 (the first does what you want, the second is a bit more "fun" )

Attachments:

Thanks for your help!

Oops forgot the other thing:

you want a List of List, int[,], int[][], matrix "options"? (only useful when doing things for usage outside the GH umbrella and therefor ... "skipping" DataTrees).

I think it'll be ok, but for your first code, could you explain again why you have three cases? (I am new to programming) 

(a) The first option "groups" the integers (as Lists) into the tree.

(b) The second adds a second dimension so you have one item per branch (but still the "grouping" is intact: first dimension as on (a))

(c) The third adds a second dimension equal with the integer value (see (b) for the "grouping"):Of course has meaning(?) if the item type is integer.

Options added just to indicate 3 out of a myriad possibilities to sample items into trees.

Of course the most "compact" (no options, intL etc etc) way is:

    DataTree<int> intT = new DataTree<int>();
    int path = 0;
    for(int i = 0; i < count;i++){
      if(i != 0 && i % div == 0)path++;
      intT.Add((i + start), new GH_Path(path));
    }

Ok, thx! 

RSS

About

Translate

Search

Videos

  • Add Videos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service