How to use IF to execute Functions

Hi all,
I’m just getting started with Dynamo I don’t quite understand the If node. Here is an example of what I’m trying to do

Thanks
MikeC

I’d use Python to send all or nothing to prevent the data flow. If based logic is usually much easier to program in Python versus on the canvas, and whilst possible in Dynamo has some limitations and legibility issues when done using nodes only. I’ve used Python here as some versions of Dynamo have undesirable behavior for If nodes where it defaults to shortest list size for what gets through the node.

send data or empty.dyn (14.8 KB)

if IN[0]:
    OUT = IN[1]
else:
    OUT = []
5 Likes

@GavinCrump has a good all or nothing option which I’ve needed many times, so thanks for sharing here on the civil side :pray:

Another option is to filter out profiles or pvis that don’t meet your grade conditions by using filter with bool mask (feed objects into “list” and the true/false results from your code block into the “mask”).

In general, and the basic way I understand it is the if node works best with equal sized lists that feed into the separate true and false nodes. For example if you have 10 bool results feeding into the “test”, you should have to have a list of 10 things to return if they are all “true”. If one of the 10 is actually a false, well, you still need a list of 10 things to return if they are false.

1 Like