Replace items in tree?

Hi all. I do face a situation in which I do need to replace the existing data in trees with new data that needs to replace the old items in the tree but I can’t find a way to do so. The first two items are identical in the old and the new data sets, but all other values are different. I do need to get the “GOOD” list replaced with the data from the “NEW Z” tree.


Replace items in tree.gh (36.2 KB)

Not really sure what you’re asking. Your ‘GOOD’ tree contains 2419 branches and your ‘NEW Z’ tree contains 2151, so I’m not sure how you want to insert data from NEW Z into GOOD - what is the rule that determines which data from NEW Z goes where in GOOD?

Yes, I do want to replace the old data in the GOOD tree into exactly the same location. If I eliminate the <null> items I will have the same data in both trees. The issue is that I do need the <null> items as they are, and only replace the existing data with the new one.

Found myself a working method. Maybe there are more better ways to do the same thing, but for now this works.


Replace items in tree_working.gh (76.8 KB)

1 Like

I think you are mixing “paths” with indexes of your data.
You might find a convoluted solution that ultimately work, but you are not supposed to use grasshopper this way.

Also, lots of nulls in your datatree, that also is wrong. Not a good practice.

If you have a broader situation where you want to re-make the overall data flow, that would be a more interesting discussion, imho.

Yes, at the end I do need to combine with other tree that contains data where this tree have nulls, so the nulls are just placeholders to don’t screw-up the tree structure.