IF Statement Issue

Why does one format of one result depend on another?
Can somebody explain to me what’s going on with IF statement?

From what I recall about this the reason you’ve only got 6 outputs in the bottom left is because of lacing.

The IF node isn’t great and it’s seeing that the false only has 6 outputs, so it only gives you 6 even though it’s true. :expressionless:

Have you tried the scope IF node instead or doing it with designscript?

Personally often do this with Python.

3 Likes

You’re right. It is also explained here.

That being said you can find a solution (workaround) here.

You might try the if/then/else node from Crumple Package. He made it through Python.

This question comes up all the time. @Alien already answered the why, but if you want more info you can just search the forum for some more in depth explanations.

Later versions of Dynamo have corrected this with an updated If node that accepts lacing and list levels while also defaulting to the expected outcome of returning entire lists.

For versions that still use this old node the easiest solution is to use the code block workaround.

i = test ? 0 : 1;
[ifTrue, ifFalse][i];

This workaround merges your true and false lists into a a single list at indices 0 and 1 respectively. The test condition then returns either index 0 or 1 based on the results and then gets the sublist at that index, ensuring that you get the entire list.

3 Likes

Note that current builds include a version of the if node which allows for replication and lacing as per any other node.

@jacob.small

Since which build?

It’s definitely in 2.13, but it may have been 2.12.