Grasshopper

algorithmic modeling for Rhino

hi all!

I have a tree with lists of integers, R, and I use that to select branches from a second list, D. This is no problem, but I want to be able to keep the branches of D hierarchically organized under the original structure of R... how do I do this?

EDIT: I guess another way to put it is I want to insert the branches of Tree D into tree R, using the values in list R as corresponding indexes.

Thanks in advance

Oliver

Views: 942

Attachments:

Replies to This Discussion

Hey Oliver, 

Attached is a definition that does what you want. As far as lexical problems go, this was kind of tricky (although there's probably a better way).

First I used the Replace Paths component to give you the data structure you're looking for, simultaneously replicating the sub-path index as the single value per branch, so that you get a data structure like {a;b}(b), in your case {45;10}(10) {45;23}(23) {45;26}(26).  

Then, a single line of C# does the rest.

A = D.Branch(R); 

The access of R must be set to Item, and the access of D must be set to Tree. This means that D will be loaded into the C# component as one huge array (that's why it takes a little while to load when you open the file). Since R is set to Item, the component will run once for each of the 1150 branches in R. Each time, the branch with the value of R (10, 23, 26) will be populated with the corresponding branch {10}, {23}, {26} of the huge array D. 

Hope that helps. When you get back maybe tell me what D and R actually mean?

N

Attachments:
Thanks Nathan! You are a boss!

This is for a recursive erosion simulation definition I was working on. I was thinking about hitting you up about that program you were working on last semester. More specifically, it uses starling to get the vertices adjacent to an initial vertex, and this was to get the second ring of adjacent vertices and still relate them to the initial vertex. Sounds like it might end up being a little cumbersome... Thanks again for the help, miss you guys!

O

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