Data Tree and Sift/Dispatch

Hello - data tree related question here.

If I have a tree with 5 branches, like shown - how can I split/sift/dispatch this by the values in each branch? When all the values in a branch are the same (such as False, False, False) then move to one list, then when values in a branch differ, move to another? Is there a way to combine the values in a branch to a single value, like True or False, then apply that pattern to the tree? I’m new to these data trees so I apologize for my ignorance. But can I sift/dispatch a list of lists, or does it only work on a flat list? Thank you

Zero = False.

1 Like

the best way would be to understand what happened upstream that created a mix of integers and booleans, and work on that

you can anyway do something like Replace Text and change 0s into 1s, then mass addition in such a way:
3 Falses = 0, 0, 0, → 0+0+0 = 0
2 Falses + 0 = 0, 0, 1 → 0+0+1 = 1
and sift/dispatch using those values

but be aware this is very not good practice :slight_smile:

1 Like

I shouldn’t have mixed types (booleans and ints…)

UniformBooleanValueSorting.gh (15.7 KB)

Hi, I am not quite clear on what you are trying to achieve, and I think your question would be better with a bit more context about why you need the results you are working with, and where is the input data coming from.

For instance are you comparing strings, as in is the character “0” same as the character “False”? I think this is unlikely, although if this is the case it can be achieved with minimal coding added in the grasshopper script.

What I assumed though, is that you are comparing Boolean values, whether something is True of False. And as has been mentioned, often in such Boolean operations, 0 is considered as False and 1 as True. (So just in case this was not your intention, it may be bad practice to mix binary number with boolean values, if you do not want people to assume they are used interchangeably).


One way to do what you need, if your tree branch length is fixed (and you need to place as many equality components as your list length minus 1, so not practical for long lists), is to compare the items within each branch, and if the same, send them one way, if different send them a different way. However you can compare any numerical values in your lists.


The other way, and probably I assume, the best way for your needs, works with any tree branch length, and the different branches of the tree need not even be equal lengths. You sum the all the values of each branch, it the sum is 0, all values are false (and the same), if the sum is equal to the list length, all values are True and the same, otherwise, the branch is not uniform. However this only works with Boolean and binary values.

Thank you very much for the detailed model and reply. That is super helpful. I will be less vague in future questions. I just getting comfortable with the basics of data trees, and these well documented responses really help.

I’m pretty amazed at the capabilities of GH/Rhino and also the responsiveness on this forum.

Thank you

1 Like