Tree operations python Grashopper

Hi all,
I am writing a simple script that takes a tree, and returns false if any of the items inside the list is false.
The script is working with my test list
#test = [[False, True,True], [True, True,True], [True, True,False]]
the result being: [False], [True], [False]

But its not working the same way with my data from GH.
What am I missing?
Below is the script and the two screenshots showing the results I get from my test vs. my data from GH.

author = “elva0068”

import rhinoscriptsyntax as rs

import ghpythonlib.treehelpers as th

y = th.tree_to_list(tree, lambda tree: tree)
#test = [[False, True,True], [True, True,True], [True, True,False]]

def booleanmix (biglst):
newbiglist =
for sublist in biglst:
for item in sublist:
if str(item) == ‘False’:
newsublst =
newsublst.append(‘False’)
break
else:
newsublst =
newsublst.append(‘True’)
newbiglist.append(newsublst)
return (newbiglist)

list = tree_to_list(tree,retrieve_base = lambda x: x[0])
a = th.list_to_tree(booleanmix(test))

Hi @Elena_Vazquez_Peña ,

import clr
clr.AddReference("Grasshopper")

from Grasshopper import DataTree
from Grasshopper.Kernel.Data import GH_Path

def check_collection(tree):
    all_true = True
    
    for path in tree.Paths:
        branch = tree.Branch(path)
        if not all(branch):
            all_true = False
            break
    
    if all_true:
        return "Collection is true"
    else:
        return "Collection has at least one or more false"

# Test data
test_tree = DataTree[bool]()
test_tree.AddRange([True, True, True], GH_Path(0))
test_tree.AddRange([True, True, True], GH_Path(1))
test_tree.AddRange([True, True, False], GH_Path(2))

output = check_collection(test_tree)
print(output)

This should correctly identify if there’s any false element in the datatree
Hope this helps,
Farouk

Hi @farouk.serragedine !
Your script indeed identifies if there is a false in the list.
However, I wish to have as output the tree structure shown in the second image (a branch per each resulting boolean).
Do you have any suggestions?

Try posting the file, that makes it tremendously easier to help. See this for reference (e.g. internalise data):

TreehelpBoolean.gh (75.8 KB)
Updated with internalized data.

Here is the file @AndersDeleuran

As suggested, you need to internalise the Brep:

Edit: Just saw the updated file. Is this what you’re looking for:


TreehelpBoolean_Anders_00.gh (77.2 KB)