Trim tree only if branch depth > 1?

On many occasions data can change structure between branch depth=1 {0} and branch depth>1 {0;0}

Trim, for example, behaves differently for those two situations.
How to filter data for those two situations ?

This is how I do it, but are there other ways? I feel that I’m missing something…

I think you should upload one def file so that others don’t have to start from scratch.Saving other people’s time will save your time at the same time.

If not needed in your use case, always use simplify to avoid redundant left-hand zeros.

Also, with the Path Mapper, you can control what happens on each case

You can use the Suirify component for this, an on-component simplify fails to simplify if you have a {0;0;0} and a {0} branch.

1 Like

you might already be aware that whatever numbers are written as path of any data tree branch, gh doesn’t really care about those, it will just pair branches 1:1

you can use Principal modifier (Right click on input) to tell the component you want the output paths to be based on the paths of a particular input

random_paths.gh (16.9 KB)

using Simplify is -generally speaking- not very good practice (I understand it can help us -humans- to better understand what is going on in data trees, but still…)

this video on the topic is super interesting and very well explained:

1 Like

But I don’t want to chage the paths. I want to keep them as they are. What i want is to stream the data in two different paths.
If i have a path with 1 depth {0} the data should go in one stream and for larger depth {0;0} data should go in another stream.

ok, that is easy :slight_smile: you can use Deconstruct Path component, which splits each path in its sequence of ints, then you can use List Length and check if the length of the List of ints is higer than 1 or not

not clear to me if you want to split a tree based on that, which means you might have a tree with paths of mixed lengths (there might be easier ways to accomplish this…)


split tree based on path length.gh (11.2 KB)

or if you want to sample just one path assuming it will reflect the path length of the whole data tree:

redirect tree based on path length.gh (11.4 KB)

1 Like

okay! yeah, Stream Gate is what i’m missing

TStat - List Item then Dpath,
then with List Length - Larger Than and Stream Gate i can replace the Python component.

This happens very ofthen when input is one geometry or several grafted geometry .

In case of one geometry i need the paths as they are, in case of several geometry I need to Trim.

So in the end I have to merge both cases and stream further, otherwise I have to code twice, once for one geometry , second for several.

Thank you!