Trace back path and save results in list

In my project I have found a way to search connecting curves out of a bunch of other curves. I did not want to use anemone, so every search is followed by a new search.
The results of this process (about 10-12 layers deep) is stored in the path (see gh file
Now I need to extract the chain of curves from end back to beginning.


in the panel last number visible (35)
is connected to (11) one layer up in path
is connected to (10)
etcetra all the way up to (0)

param viewer gives an idea on the tree structure.

Now I want to learn how to extract these numbers {35;11;10;--------;0} to a list
Because with that list (of indexnumbers) I have the chain of curves connected.

Would love ideas on:

  • how to solve this :slight_smile:
    but more on what tools out of the components for working with trees/dataset would be usefulle here.

Regards, Eef
trace back in path to list.gh (7.8 KB)

Have you tried the topologizer plugin by @DanielPiker it seems it does what you’re looking for…

If you want to stick to your process, look at the ‘relative item’ component.

Maybe list item already does what you want.

Thank you Martin,

I want to do it with the common components (otherwise, exporting to excel, transponing, would already do the job).
I will check relative item,
for list item.. I have to turn the upper laying branches into seperate lists.
I and will check the plugin, just to better understand how these trees and set work.

how would I know this unless you were writing it down?

I think it would be MUCH easier to do -even with standard components only- if you could supply the curves (eventually with the definition you used to get to this data, but not necessarily)

It is primary about learning how this works, secondary how to solve the issue, that’s why I would love to stick to working on these datatree questions

If I understand this will. The branch numbers lead the way back?
if 35 would be connected to the nr 12, then the branch would have another number:
the branch would have the number 1 in it (on the correct level) etcetera.

As example a smaller version (with just two levels)
II trace back in path to list.gh (9.8 KB)


(your drawing is better then mine :wink: )
you see how the branch numbers reflect the source.
so any number in the second (green) panel can be traced back: (if I would know how to do this):
example: nr 16 is in branch (0;0;0;3)
and is a child of the third item in the first (yellow) panel = 17
What I want as a result would then be a list with (16 17)
what represents a chain of two connected curves

ok, I think I have understood :+1: but I think it’s a bit complicated :slight_smile:

I have simplified the tree by removing empty branches, so they stay in one screen, you are trying to retrieve some data like this:

I think it would be easier if, in the portion of definition that comes before the data you shared, you would make in such a way that ancestors get propagated in the result of your search

so you start the definition on the first segment that we call “a”:

{0}: a

it finds for instance 3 connected curves, named b, c, d, and creates a new level in the path, now it does:

{0;0}: b
{0;1}: c
{0;2}: d

it would make life easier if it would becomes instead:

{0:0}: [a, b]
{0;1}: [a, c]
{0;2}: [a, d]

I’m not able to think about a non-looping solution, not even using just vanilla GH components, I think it’s much easier if that data structure you are looking for gets embedded in the result from the beginnig… but keep in mind that the “manual loop” used for the 12-levels-depth of search can get you in a black hole pretty fast :slight_smile:
when possible (meaning “always”, it’s just a matter to find the best way to do it ) it’s always better to not loop stuff by hand, because if you have repeated it 10 times and want to make a tiny change, it reflects into 10 tiny changes… and generally speaking you can’t loop things by hand 5000 times, while anemone or code can do that in a very easy and straightforward way


a coded version would look like this (credits to ChatGPT):

trace back in path to list_ChatGPT.gh (12.5 KB)

I am going to explore that approach, and just insert the “search” number into a second “results” list.
Meanwhile I checked many components to do, what (in my eyes looks as simple) but I could not get it working: get the path belonging to a list item.


Maybe I am blind with both eyes open. Thanks for your help. Regards, Eef

you can use a grafted Tree Stat for that:

Yes, that would work fine.
Your suggestion to propagate the ancestors works very nice. I will stick to that.

Regards, Eef