Combine 2 trees based on specific branch number in tree

Hi,

question;

There are 2 Trees;

Tree A:
contains a branch structure with ‘4 branch depth’, all containing 1 value

Tree B;
contains ‘1 branch depth’ and contains, all containing 1 value.

Question;

I would like to add the values of Tree A + Tree B, whereby;

The tree branch of list B has so correspond to the 3rd ‘branch’ of list A.

Whereby the resulting tree has the same datastructure as tree A

Any suggestions?

thanks :slight_smile:

2020-11-11 Add 2 lists based on a specific branch number.gh (24.4 KB)

Quick way using Path Mapper:

2020-11-11 Add 2 lists based on a specific branch number MBH.gh (33.0 KB)

Thank you for your answer.

Unfortunately the output is not correect.
This has to do with the fact when using the path mapper to c, multiple items get in the same list, while they are in a differt order in the original list. see below.

any suggestions how to overcome?
Thank you once again.

Ah yeah sorry I was being pretty hasty. Knew it was a quick n dirty method, will have another go!

OK how’s about now

Not a very elegant solution, but to make it better I’d need to understand why you’re doing this so that there may be a better way around this problem. Works for now though.

2020-11-11 Add 2 lists based on a specific branch number MBH.gh (38.1 KB)

Hi, Thank you :slight_smile:

The outcome is correct.
yes agree, I will explain it a bit more:

The number of items in Tree B can change, so e.g. it is possible there are not 3 items but 5;
{0}, {1}, {2}, {3}, {4}

The script is perfect, till the unweave component. would it possible to make this part a bit more generic?
so there are not only 3 output items present, but possibly more (or less).

thanks again!

I’m not sure if it’s possible (or practical at least). You’d be better off revising your data structure to make this section simpler. That’s what I mean where I say I’d need to understand more about what you’re trying to do more holistically rather than just trying to solve this localised problem. It might be that streamlining the data flow further up the chain is a better answer, but without seeing the chain I can’t help

Together with your script I did found it!

thanks again! :slight_smile:
2020-11-11 Add 2 lists based on a specific branch number_re.gh (25.6 KB)

1 Like