We have changed the functionality of the “If” node in Dynamo. Previously the “If” node would work like a conditional statement, similar to the inline condition in DesignScript. So when the ‘trueValue’ and ‘falseValue’ had list values of different lengths it would replicate over the shortest length. This was a little confusing to the users as they were seeing unexpected output. The same would happen with empty lists and null values.
To avoid this confusion, we have decided to update the “If” node functionality and the node would directly return the complete ‘trueValue’ or ‘falseValue’ based on the input ‘test’ condition. This would handle lists of different lengths, empty lists and null values. If the ‘test’ has a list of boolean values, the output of the “If” node will replicate on that list. Note that this node will replicate only on the ‘test’ input parameter.
We have a Dynamo build which has this new node and for now, this new node has the same name. We encourage you to try this build out and let us know if think of any other changes. We will be glad to incorporate them.
The old node is hidden from the library and the new node can be used. We are supporting backwards compatibility for this node till we completely obsolete the old “If” node. If you open up any old graphs with the “If” node, the graph will execute like before and the node will show a warning message to update it.
Sandbox Daily Build to test the new “If node” available here. Please either use 7Zip to unzip, or manually unblock the ZIP file before opening, as discussed below:
In order to use the DynamoCoreRuntime.zip files on windows operating systems, please use 7zip to extract the files or alternatively, manually unblock the zip archive before unzipping it. For more information on the DynamoCoreRuntime builds and how to setup your machine please see our wiki page.
Hello @Nick_Boyts - We are happy to investigate support for List@Levels and Lacing should the need arise.
With the link to the ZIP file above containing the new If Node version - would you be able to show us use cases that it doesn’t cover, which List@Level would?
@Steven the old If node used the following DesignScript code under the hood: result = test_condition ? truevalue : falsevalue;
This DS conditional statement replicates over all 3 inputs, namely, test_condition, truevalue, and falsevalue.
The new If node, uses the following DS code under the hood: [truevalue, falsevalue][test_condition ? 0 : 1];
This new code does not replicate over truevalue or falsevalue but continues to replicate over test_condition.
So to answer your question, the original DS conditional statement has not changed in behaviour. We have only replaced the underlying guts of the Ifnode to make it more intuitive.
Honestly I’m not sure if I have anything off the top of my head, but I feel like I’ve ran into this situation before. At least with the new node it would only take some minor list duplication to get the same outcome. I’ll see if I can put an example together.
This is obviously a made-up use case so there are probably better ways to handle this, but this is essentially what I had in mind: a scenario where you have a list of booleans representing sublists within the true/false results.
Again, it wouldn’t take much to get the desired result with some minor list manipulation, so this isn’t really a big deal, but it could be done with list levels. I may also be missing something.
This has been the DS workaround for a while. Essentially just get the sublist at the specified index rather than filter a mismatched dictionary. Completely circumvents the IF node.
Yes, @Nick_Boyts is correct. It’s not a newly supported syntax in DS, just a terse syntax. Essentially it packs the true and false values into a list and then indexes it by a 0 or 1 depending on which is the output from the inline conditional (ternary operator). This is possible due to the fact that anything inside an indexer [] can be an expression as long as it results in an integer. By “new” code I meant it was “new” for the If node.
The underlying behavior of the If node has been changed. Please refer to this comment from Aparajit to understand the difference in behavior between the old and new IF node.
The RIE_If node takes in a list for all the input parameters so there is no replication happening for that node.