Grasshopper

algorithmic modeling for Rhino

Hi all,

Currently my data is organized in this data tree structure:

{0;0},{0;1},{1;0},{1;1},{2;0},{2;1}

I would flip the matrix so that the second index become the first and also group in it all the elements contained in the other branches with equal second index. Example:

{0} contains items that in {0;0},{1;0},{2;0}

{1} contains items that were in {0;1},{1;1},{2;1}

Do you have any suggestion to give me?
Thank you

J

Views: 2180

Replies to This Discussion

You can use the Split Tree component with a mask. 

The mask is filled in the orange panel. {?;0} means that the component is going to look for every branch starting with first index : "?" (means, any number), second index "0".

See this post to play with the masks : 

http://www.grasshopper3d.com/forum/topics/datatree-selection-rules

Hi J,

There are three methods that I regularly use for these types of data tree manipulation.  

If your data tree structure never changes using the Treesloth shift paths component is a quick and reliable option (top group in the image below).

However, if your data structure might be changing I think it's better to use something a bit more robust, like replace paths component paired with some text manipulation components to ensure that you always get the desired results (middle group in the image above).  As long as you don't have too many branches this is my preferred option.  In the example above I made a list with 50,000 items in 50 branches.

The third option is to do something similar using some Tree Frog components to replace the standard Grasshopper replace paths component (bottom group in the image above).  Although this is the slower option when there are many items and few paths (as shown above).  It starts to become the quicker option when you have many branches in your data tree (as shown below).  In the example below I made a list with 50,000 items in 10,000 branches.

The examples that I put together always collapse the data tree to the front-most part of the path, however with either of the two bottom approaches it would be pretty easy to change that behavior dynamically within the script.  I'm sure there are a million other ways to approach this problem and can't wait to see other solutions, but that's my two cents.  The attached GH file shows these approaches and requires treesloth and tree frog to open.  Good luck!

Attachments:

Thank you guys for the prompt reply!

@Ryan: That's exactly what I was looking for...My data structure is not fixed so I will go for the second option that you suggested!


Thanks again

There's another potential solution here with some new-ish metahopper components: 

I've attached the latest metahopper too since it includes some stuff not yet on the f4r page.

The idea of Wrap/Unwrap is that it turns branches into items so you can use regular list manipulation tools to control them. 

Attachments:

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