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


#1

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.


#2

You could try an If node.

31


#3

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).


#4

Cat o fam.dyn (6.6 KB)


#5

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.


#6

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.


#7

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


#8

@dalessandro.michele

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


#9

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


#10

@PauLtus

the designscript method is independant of installed packages


#11

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


#12

@PauLtus

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.


#13

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


#14

More info on the issue can be found on github: https://github.com/DynamoDS/Dynamo/issues/6491


#15

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)


#16

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 !


#17

You’re welcome!


#18

there is also a ScopeIf OOTB node:


#19

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!


#20

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