Grasshopper

algorithmic modeling for Rhino

Hi!

I've got two data trees with different structure. The first one is like {A;B;C;D;E;F} and the second is more like {A;B;C}.

The first three branches of both trees are the same.

What I want is to match every branches of the first tree with the branches of the second one which begin in the same terms, without losing the first data tree structure.

For example, I'd like to match these kind of branches of the first tree {1;1;3;X;Y;Z} with the branch {1;1;3} of the second tree without losing the structure {1;1;3;X;Y;Z}

Is there a way to do this easily?

Thank you

Julien

Views: 11081

Replies to This Discussion

Shift Paths component set to -3 for the first tree will move all of the data onto the correct branch to match with the second Tree.

Alternatively you can use the Path Mapper set to {A;B;C;D;E;F} --> {A;B;C}

Thanks Danny for your answer!

I've already tried these solutions, but I want to keep the structure of the first tree (i.e. {A;B;C;D;E;F})
What I want is to match the branches like this

all the items in{0;0;1;x;y;z} with the item in {0;0;1} -----> items in output {0;0;1;x;y;z}

all the items in {0;1;1;x;y;z} with the item in {0;1;1} -----> items in output {0;1;1;x;y;z}

....and so on

I've read old discussions about this issue but I didn't find the answer.

Thanks again

I think this discussion contains a few viable strategies. Vicente's script may do exactly what you're looking for. 

Without the use of that script (or some other scripting solution), I can think of two general strategies in this case. One is to do as Danny suggests and discard the extra data from the first set of paths, put them together in whatever component you're doing the matching on, and then coerce the results back into the tree structure of the original first path using a path-replacement strategy.

I wrote a script that assigns an arbitrary path structure to a set of data, which runs significantly faster than replace paths; that could be used for this method as well. 

The second strategy would use a series of list-lengths and duplicate-datas in order to make the second tree's structure match the first. 

See the file attached for examples of all of these strategies. 

Attachments:

Thank you so much Andrew! this is exactly what I was looking for!

Yep, Andrew is awesome.  He has helped me several times with really meaningful feedback... clearly a GH master.  He must live a life bathed with good Karma.  Nice work Andrew.

Awesome script Andrew! Thanks for sharing!

 

Best regards

Morten, Cph Denmark

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