Re-arranging branches into a new tree

Hi all,

I am trying to re-arrange branches from a tree based on the structure from another separate tree.

As you can see below I have tree A and tree B. I would like to input the values of branches in tree A into tree B as if each value of tree B was a path of tree A.

Input:

Output:

I have managed to do get to the required output but with some limitations which are not acceptable:

  • Option 1, number of paths in both trees will vary and will most of the time not be equal and “match tree” component will not work for these cases.

  • Option 2, the number of path in tree B will be also varying and I will have to manually add output in the explode tree which is not practical.

I feel like I am missing something fundamental here as my understanding of trees tells me that the simple option 3 below should work but it is just giving me back the structure from tree A.

Thanks,

Arthur

Redistributing Tree.gh (11.3 KB)

…or like this, if there is no sequential order of branches in Tree B…

Thank you for your prompt response Jakinta.

I have tried with my actual trees and your first option does not seem to work as I only get 6 branches in the output.

The second option gives me the right number of branches but the branch sequence from the tree B is actually critical for the next steps in my script.

I have attached below the actual tree A and tree B I am working with.

Redistributing Tree - Actual Trees.gh (61.1 KB)

Option 1 does not work if tree A and B have unequal paths.

Since Tree B appears to be a direct reference to the branches in Tree A, I see no reason to believe that a mismatch between the two should yield sensible results?

This (below) is ridiculous, of course.


Redistributing_Tree_2020Feb20a.gh (8.9 KB)

Here it is again using your “Actual Trees”. I have no idea if the results make any sense. 3296 in Tree A and 3019 in Tree B results in 163735 numbers??? The basic premise seems flawed since there are only 60 branches in Tree A?


Actual_Trees_2020Feb20a.gh (30.2 KB)

Setting List Item ‘W’ (Wrap) to False ignores references from Tree B that exceed the number of paths in Tree A, so the results are reduced to 127453 instead of 163735.


Actual_Trees_2020Feb20b.gh (30.2 KB)

Not sure if this is what you are looking for:

Redistributing Tree - Actual Trees_V2.gh (57.4 KB)

1 Like

How you want get 53 branches ?

@Joseph_Oster Thanks! Your solution appears to work perfectly for my purpose. The use of the group component to input branches into a list item component in order to extract the branches is interesting and something I will try to use more.

Right now I cannot see a difference when setting the Wrap option of the list item component to True or False but I will keep that in mind if something does not seem to align down the line.

If there were no difference I wouldn’t have mentioned it. I don’t understand the full context of what you are doing but can see some consequences of this approach. With ‘Wrap = True’ (the default), index references in ‘Tree B’ that are greater than the number of branches in ‘Tree A’ create duplicates. A total of 163735 results instead of 127453 when ‘Wrap = False’. Using Cull Duplicates (CullPt) reveals that in fact, there are only 107500 unique results.