Adding values from data trees with different number of branches

Hello!

I have 2 data trees. The first one consists of 5 branches {0}, {1}, {2}, {3}, {4} and the second one of 3 branches with each one having 5 additional branches {0;0}…{2;4}. I would like to take the values from the second data tree and add to them the values from the first data tree. So it would go… {0;0} + {0}, {0;1} + {1}…{2;4} + {4}. What would be the best way to achieve this?

Adding data trees.gh (12.5 KB)

It could be one of many ways…


Adding data trees_re.gh (12.5 KB)

1 Like

This is also a possibility.

Adding data trees-re.gh (12.5 KB)

1 Like

This looks a little ridiculous compared to @HS_Kim’s simple code, especially since the purple group is all to get one number: 3. But the original tree structure of the second panel is preserved.


Adding data trees_2023Mar17a.gh (17.1 KB)

1 Like

Yup, this works, although the original structure is lost. Would rather preserve it.

Ta-daaaa !

1 Like

I was thinking of doing something similar aswell. However your specific solution seems to have an error in it. The final data tree has 15 items in each branch. But it should be 10 as in the original tree.

Damn, well you have a couple of other solutions to chose from. :wink:

Yup, this works great! Achieves exactly what I wanted.

You can Match Tree at the end. @HS_Kim solution is great since it works for any amount of copies.

Yup, this is exactly why I thought about posting here. That there is probably a stupidly simple solution I couldn’t find. Great work!

RMB on the B input and check “Principal” would resolve the problem.

2 Likes

Thank you everybody for the great solutions! I think there are more than enough now :smiley:

Or you know, just switch A and B :smiley:

Here is a way yo simplify the purple group.


Adding data trees_2023Mar17b.gh (17.6 KB)

And my method doesn’t?

1 Like

It absolutely does. I prefer icons :smile:

I can’t read your code either. :wink: Worse than icons, it appears to me as “Draw Full Names”. Ugh!