How to understand ScopeIf?

ScopeIf is typically meant for use inside custom nodes. It often fails when used in the graph environment (though it can work if used carefully). The purpose of ScopeIf is to only execute the nodes connected to the conditional input matching the test condition. i.e. If your test condition is true then the nodes feeding the true input will run as expected and return an output while the nodes feeding the false input will not execute at all.

You can see here that the nodes return nulls even though ScopeIf still returns the correct value.

The problem with using this node in the graph environment is that you often have inputs that connect to other nodes that still need to run regardless of the scoped execution. In this example the test condition is tied to one of the scoped inputs which makes a cyclical dependency on having to execute both conditions in order to determine the test outcome. This cause everything to fail.
image967×314 32.9 KB

5 Likes