# \[Request for Feedback\] Refactored the "If" Node

**URL:** <https://forum.dynamobim.com/t/request-for-feedback-refactored-the-if-node/60647>\
**Category:** Request for Feedback\
**Tags:** dynamo\
**Created:** [February 18, 2021, 5:25pm UTC](https://forum.dynamobim.com/t/request-for-feedback-refactored-the-if-node/60647 "2021-02-18T17:25:10Z")\
**Posts on this page:** 15\
**Page:** 1

<div class="post-metadata">

**Author:** ![ashish.ganta](https://avatars.discourse-cdn.com/v4/letter/a/ea5d25/32.png) [@ashish.ganta](https://forum.dynamobim.com/u/ashish.ganta)\
**Post date:** [February 18, 2021, 5:25pm UTC](https://forum.dynamobim.com/t/request-for-feedback-refactored-the-if-node/60647/1 "2021-02-18T17:25:10Z")

</div>

Hello Dynamo people!

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.

- Original thread regarding the “If” node: [[Request for Feedback] If Node](https://forum.dynamobim.com/t/request-for-feedback-if-node/45257)
- Sandbox Daily Build to [test the new “If node” available here](https://myshare.autodesk.com/:f:/g/personal/sol_amour_autodesk_com/EsnXl2A6TthNnIM3plaR730B9xUicQnyhn-gimK4qhJWdg?e=60a8tO). 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](https://www.7-zip.org/) 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.](https://github.com/DynamoDS/Dynamo/wiki/How-to-Utilize-Dynamo-Builds)

[New\_If\_Node.dyn](https://forum.dynamobim.com/uploads/short-url/fEPzVv8A5S1mSjSSMdM4JgRSAUD.dyn) (152.6 KB)

---

<div class="post-metadata">

**Author:** ![Nick\_Boyts](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/nick_boyts/32/76313_2.png) [@Nick\_Boyts](https://forum.dynamobim.com/u/Nick_Boyts)\
**Post date:** [February 18, 2021, 6:03pm UTC](https://forum.dynamobim.com/t/request-for-feedback-refactored-the-if-node/60647/2 "2021-02-18T18:03:55Z")

</div>

> [@ashish.ganta](#):
>
> Note that this node will replicate only on the ‘test’ input parameter.

I assume that means it will continue not to support list levels?

---

<div class="post-metadata">

**Author:** ![Steven](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/steven/32/112504_2.png) [@Steven](https://forum.dynamobim.com/u/Steven)\
**Post date:** [February 18, 2021, 6:10pm UTC](https://forum.dynamobim.com/t/request-for-feedback-refactored-the-if-node/60647/3 "2021-02-18T18:10:25Z")

</div>

> [@ashish.ganta](#):
>
> Previously the “If” node would work like a conditional statement, similar to the inline condition in DesignScript.

Does this mean the DesignScripts if function will not be updated with the new _if_ node?

> [@What if you have more than 1 if statement?](https://forum.dynamobim.com/t/what-if-you-have-more-than-1-if-statement/13369/20):
>
> I think @jacob.small nailed it. I started to give it a try before he posted and then continued for my own benefit. Thanks, for the clean solution Jacob. Failed solution 1: [image] Failed solution 2 (Basically the same as above): [image] Working solution (same concept as Jacobs): [image] It looks like the new if node will be able to accommodate this function. [https://forum.dynamobim.com/t/request-for-feedback-if-node/45257/23](https://forum.dynamobim.com/t/request-for-feedback-if-node/45257/23)

---

<div class="post-metadata">

**Author:** ![solamour](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/solamour/32/153516_2.png) [@solamour](https://forum.dynamobim.com/u/solamour)\
**Post date:** [February 18, 2021, 6:54pm UTC](https://forum.dynamobim.com/t/request-for-feedback-refactored-the-if-node/60647/4 "2021-02-18T18:54:53Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![john\_pierson](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/john_pierson/32/191977_2.png) [@john\_pierson](https://forum.dynamobim.com/u/john_pierson)\
**Post date:** [February 18, 2021, 7:21pm UTC](https://forum.dynamobim.com/t/request-for-feedback-refactored-the-if-node/60647/5 "2021-02-18T19:21:22Z")

</div>



---

<div class="post-metadata">

**Author:** ![Aparajit\_Pratap](https://avatars.discourse-cdn.com/v4/letter/a/f07891/32.png) [@Aparajit\_Pratap](https://forum.dynamobim.com/u/Aparajit_Pratap)\
**Post date:** [February 18, 2021, 8:15pm UTC](https://forum.dynamobim.com/t/request-for-feedback-refactored-the-if-node/60647/6 "2021-02-18T20:15:53Z")

</div>

@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 `If` **node** to make it more intuitive.

---

<div class="post-metadata">

**Author:** ![Nick\_Boyts](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/nick_boyts/32/76313_2.png) [@Nick\_Boyts](https://forum.dynamobim.com/u/Nick_Boyts)\
**Post date:** [February 18, 2021, 10:31pm UTC](https://forum.dynamobim.com/t/request-for-feedback-refactored-the-if-node/60647/7 "2021-02-18T22:31:55Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![solamour](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/solamour/32/153516_2.png) [@solamour](https://forum.dynamobim.com/u/solamour)\
**Post date:** [February 18, 2021, 11:32pm UTC](https://forum.dynamobim.com/t/request-for-feedback-refactored-the-if-node/60647/8 "2021-02-18T23:32:32Z")

</div>

Ok cool! We also couldn’t really figure out use cases that wouldn’t be served by this change 🙂 If anyone can showcase us them then great!

---

<div class="post-metadata">

**Author:** ![Nick\_Boyts](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/nick_boyts/32/76313_2.png) [@Nick\_Boyts](https://forum.dynamobim.com/u/Nick_Boyts)\
**Post date:** [February 19, 2021, 4:05pm UTC](https://forum.dynamobim.com/t/request-for-feedback-refactored-the-if-node/60647/9 "2021-02-19T16:05:57Z")

</div>

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.

 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/7/a/7a6db2614edfc28d30f12a7218455db03c3fd877.png)

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. 🤷‍♂️

---

<div class="post-metadata">

**Author:** ![Steven](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/steven/32/112504_2.png) [@Steven](https://forum.dynamobim.com/u/Steven)\
**Post date:** [February 25, 2021, 5:49pm UTC](https://forum.dynamobim.com/t/request-for-feedback-refactored-the-if-node/60647/10 "2021-02-25T17:49:30Z")

</div>

Thanks for the response @Aparajit_Pratap,

> [@Aparajit\_Pratap](#):
>
> The new If node, uses the following DS code under the hood:  
> `[truevalue, falsevalue][test_condition ? 0 : 1];`

Has this style of DS always been around or is it new along with the IF node? More of a curiosity question.

Thanks,  
Steven

---

<div class="post-metadata">

**Author:** ![Daniel\_Hurtubise](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/daniel_hurtubise/32/146534_2.png) [@Daniel\_Hurtubise](https://forum.dynamobim.com/u/Daniel_Hurtubise)\
**Post date:** [February 25, 2021, 6:45pm UTC](https://forum.dynamobim.com/t/request-for-feedback-refactored-the-if-node/60647/11 "2021-02-25T18:45:55Z")

</div>

To simply answer the question… great news 🙂

---

<div class="post-metadata">

**Author:** ![Nick\_Boyts](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/nick_boyts/32/76313_2.png) [@Nick\_Boyts](https://forum.dynamobim.com/u/Nick_Boyts)\
**Post date:** [February 25, 2021, 7:39pm UTC](https://forum.dynamobim.com/t/request-for-feedback-refactored-the-if-node/60647/12 "2021-02-25T19:39:29Z")

</div>

> [@Steven](#):
>
> Has this style of DS always been around or is it new along with the IF node?

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

---

<div class="post-metadata">

**Author:** ![Aparajit\_Pratap](https://avatars.discourse-cdn.com/v4/letter/a/f07891/32.png) [@Aparajit\_Pratap](https://forum.dynamobim.com/u/Aparajit_Pratap)\
**Post date:** [February 25, 2021, 8:41pm UTC](https://forum.dynamobim.com/t/request-for-feedback-refactored-the-if-node/60647/13 "2021-02-25T20:41:11Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![truevis](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/truevis/32/8634_2.png) [@truevis](https://forum.dynamobim.com/u/truevis)\
**Post date:** [February 1, 2022, 10:06pm UTC](https://forum.dynamobim.com/t/request-for-feedback-refactored-the-if-node/60647/14 "2022-02-01T22:06:41Z")

</div>

I was replacing old `If` nodes to the new kind. I got different results from the original and broke my graph.

 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/3/c/3cf0f07c085e2fdf323702034b4d5b70dbf72aba.png)  
Hence, I used `RIE_If` to stop getting a warning. How could I have used the new `If`? Levels?

---

<div class="post-metadata">

**Author:** ![ashish.ganta](https://avatars.discourse-cdn.com/v4/letter/a/ea5d25/32.png) [@ashish.ganta](https://forum.dynamobim.com/u/ashish.ganta)\
**Post date:** [February 15, 2022, 3:39pm UTC](https://forum.dynamobim.com/t/request-for-feedback-refactored-the-if-node/60647/15 "2022-02-15T15:39:58Z")

</div>

Hello truevis,

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.

> [@\[Request for Feedback\] Refactored the "If" Node](https://forum.dynamobim.com/t/request-for-feedback-refactored-the-if-node/60647/6):
>
> @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 origi…

The RIE\_If node takes in a list for all the input parameters so there is no replication happening for that node.

To understand the list levels better, please refer to this post here: [Introducing List@Level: Working with Lists Made Easier - Dynamo BIM](https://dynamobim.org/introducing-listlevel-working-with-lists-made-easier/)

If you could share a sample graph with the inputs you have been using, it would be useful for us to help you get the desired result.
