Grasshopper

algorithmic modeling for Rhino

Reconstructing Tree Structure from Object User Dictionary

I'm currently using a workflow where I bake amphitheater seating geometry from Grasshopper into Rhino along with seating data using Elefront to define a series of key/value pairs per seat (e.g. section #, row #, seat #, various value metrics, etc.).

I can also use Elefront to bring this data back in along with the geometry, but the geometry comes in flat. Normally I would grab a corresponding tree structure from somewhere upstream in the definition or internalize the structure if I'm starting a new definition and then apply this to an unflatten component to restructure the geometry.

However, I got to wondering if I could use the flattened row and seating data from my object's user dictionary to reconstruct a tree. To keep things simple, I start the numbering at 0 instead of 1 to match the way Grasshopper indices work.

If I have 2 sections, each with 3 rows, and the rows have 4, 5, and 6 seats respectively, my seat data per seat would look like this (spaces are for pattern clarity):

0123 01234 012345 0123 01234 012345

And my row data per seat would look like this:

0000 11111 222222 0000 11111 222222

I was able to use these two numerical patterns alone to reconstruct the tree but I suspect my solution is inefficient. I'm including images and the definition itself in case anyone wants to take a stab at it.

Views: 2055

Attachments:

Replies to This Discussion

Hi Brian,

If you use a recent version of Elefront, the "RefBake" component automatically reconstructs the data tree in which the objects (chairs) where baked. You can toggle this on or off by right-clicking the component. Make sure to use a bake name when baking though. 

Hope this helps.

Hi Brian,

Reading your post a little closer, I realize that there are more interesting ways to deal with your question. I have created a "Tree builder" component (I think I should make it a part of Elefront) that lets you assign an explicit path per object. I have uploaded this component for you. You could basically craft a path based on your chair properties and graft the tree in one go:

Alternatively, you could use a series of Elefront "Filter by User Attributes" components to get to where you need. First filter by row (use a "Set" component to find all possible rows), then filter by section and so on and so forth. The filter component will keep adding depth to your tree, based on your filter conditions.

Attachments:

Ramon, this is great. Thanks for sharing. I'll give all of these suggestions a whirl to see what's the best fit for the workflow. And yes, I think adding the Tree Builder to the next build of Elefront would be much appreciated.

B

Tree frog also has this capability, to explicitly assign paths to a list of data - it's called "Assign paths."

Ah I missed that! Thanks Andrew.

Well it's confirmed: Ramon and Andrew, you're both awesome.

Thanks again for the assist.

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