How to set up a "boolean gate" to pass lists conditionally?

Hello! I am a new user. I would like to ask for your help. I have to create a small program that allows me to select elements by Category or by Family. The problem is that it returns me an incomplete list, it always returns me the number of elements of the shorter list. I would like it to return the whole list to me.

You could try an If node.


Thanks for the reply. I tried with an if node but the result is always the same. I have two lists, one with 7 elements and the other with 44. Whatever the value of the Boolean operator is, the result is always a list with 7 elements (ie the number of the shortest list).

Cat o fam.dyn (6.6 KB)

Use a list.count node with longest lacing to return the length of both lists. Then a list.sortbykey node to sort your two lists by with the lengths as the key. Then a list.firstitem node to get the first list.

I first saw this workaround from @Andreas_Dieckmann and quite like it:

You build a list of your results and pass an index insteadof the actual results.


I actually turned this into a node: ScopeIf+ in Clockwork.



Maybe this will help to understand the IF statement in dynamo.


What’s the advantage of using that over using an if node the general way?


the designscript method is independant of installed packages

…if I’m honest I still don’t get it.
But it may not be that important, I was just curious :grimacing:.

1 Like


In this case in both examples there are no nodes used from installed packages.
But if it were, you could run the graph with designscript in it on any computer so you can share the graph and it would always work.

1 Like

I think I should’ve looked at the rest of the thread a bit more, I get it now. Thanks!

More info on the issue can be found on github:

1 Like

Thanks to all of you for the answers. I have read your suggestions and your solutions. By reasoning on it, I too came to a solution, which I now publish to bring it to your attention. I really liked the solution suggested by @Dimitar_Venkov and the IF advice from @NLDaniel. Thanks again
Cat o fam3.dyn (11.7 KB)

1 Like

same as michele here, i have read your suggestions and solutions which are super helpful so i wanted to say a really big thanks for everything !

1 Like

You’re welcome!

there is also a ScopeIf OOTB node:


1 Like

Thanks, it’s the best solution.
Now I do not remember well, but I think I tried with a ScopeIf node without getting the same result. Now works!

1 Like

I had issues with ScopeIf in large/complex graphs. That‘s the reason I built my own version.