Split the list by boolean

I want to split the list using a Boolean list as shown in the image.
These should be split before False.
Is there any solution?

Use Node : AllIndicesOF and feed it with True of false to get the relative ,then GetItemAtIndex to get the ture of false list items.

Or Use Filter by Bool Mask.

Do you have any reference images?

Is this a description of List.FilterByBoolMask?

Yes

Can you tell me how to do this exactly?

I would like to have such a list, so the above does not solve the problem.
image

@jj06jj

Here, just insert the code bellow into a Python Script node, you can create a custom node afterwards to keep using it repeatedly.

main_list = IN[0]
bool_list = IN[1]
falseindices = []
count = 0
for bool in bool_list:
	if bool == False and count != 0:
		falseindices.append(count)
	count += 1
res = [main_list[i : j] for i, j in zip([0] + falseindices, falseindices + [None])]
OUT = res
1 Like

Thank you!
But can this be solved only with Dynamo without using Python?

You can wrap that Python Script into a custom node…
That being said, the requested result is kinda custom, I don’t think I would bother to figure out a way to do it with built-in nodes…

@jj06jj

Yes, it is possible. You can use OOTB option or the node from Sastrugi package as shown.
SplitList.dyn (22.8 KB)

Thank you!
It was simpler and much more helpful than the method I thought of.

1 Like