# IF statement with different outcomes

**URL:** <https://forum.dynamobim.com/t/if-statement-with-different-outcomes/83174>\
**Category:** Uncategorized\
**Created:** [November 16, 2022, 1:19pm UTC](https://forum.dynamobim.com/t/if-statement-with-different-outcomes/83174 "2022-11-16T13:19:46Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![Alien](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/alien/32/40701_2.png) [@Alien](https://forum.dynamobim.com/u/Alien)\
**Post date:** [November 16, 2022, 1:19pm UTC](https://forum.dynamobim.com/t/if-statement-with-different-outcomes/83174/1 "2022-11-16T13:19:46Z")

</div>

I am feeding the nodes labelled 1 ,2 and 3 with the same information

**1** is in designscript

**2** is a custom node with the Python shown.

**3** is a Python node with the same Python code as the custom node

I get 3 different outcomes.

**1** just gives me the first half of the list. I think this has something to do with shortest lacing?

**2** removes a level - why?

**3** is the one I want. onput == output

Sorry for the messy snip.

 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/b/b/bb01c7c2149316dba29f0fe0af66d4a4500e60b0.jpeg)

---

<div class="post-metadata">

**Author:** ![jw.vanasselt](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/jw.vanasselt/32/133533_2.png) [@jw.vanasselt](https://forum.dynamobim.com/u/jw.vanasselt)\
**Post date:** [November 16, 2022, 1:40pm UTC](https://forum.dynamobim.com/t/if-statement-with-different-outcomes/83174/2 "2022-11-16T13:40:04Z")

</div>

Hi @Alien,

I guess the designscript is a lacing issue.  
See this topic:  
[How does lacing work in Design Script? - DesignScript - Dynamo (dynamobim.com)](https://forum.dynamobim.com/t/how-does-lacing-work-in-design-script/72237/12)

---

<div class="post-metadata">

**Author:** ![Draxl\_Andreas](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/draxl_andreas/32/145744_2.png) [@Draxl\_Andreas](https://forum.dynamobim.com/u/Draxl_Andreas)\
**Post date:** [November 16, 2022, 1:53pm UTC](https://forum.dynamobim.com/t/if-statement-with-different-outcomes/83174/3 "2022-11-16T13:53:36Z")

</div>

@Alien ,

you can indexing in the contition too…

 ![grafik](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/7/c/7cdc457bdd7cebdfcc6d111f3e7316d81131a9b7.png)

---

<div class="post-metadata">

**Author:** ![Alien](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/alien/32/40701_2.png) [@Alien](https://forum.dynamobim.com/u/Alien)\
**Post date:** [November 16, 2022, 3:01pm UTC](https://forum.dynamobim.com/t/if-statement-with-different-outcomes/83174/4 "2022-11-16T15:01:25Z")

</div>

I tried that already and it doesn’t work.

My width and height are just integers.

It’s groups and lines that are lists.

Doing that actually splits the lines into a list structure like ‘groups’ which is not what I want.

I want the output to match EXACTLY the list structure of the input.

I’ve just answered the Python question though.  
I had plugged in the wrong input for the custom node 🤦

---

<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:** [November 16, 2022, 3:11pm UTC](https://forum.dynamobim.com/t/if-statement-with-different-outcomes/83174/5 "2022-11-16T15:11:53Z")

</div>

The nodes don’t seem to have the same inputs. Or at least we can’t tell. Can you clean it up so we can see each of the inputs and all nodes use the same source of inputs?

DesignScript (just like nodes) will assume list levels. If you don’t specify those list levels or intended list structure for custom nodes, you can’t guarantee the same outputs. You’re supplying a single boolean as your conditional input but multiple sublists for your outputs. This is a mismatch in structure.

---

<div class="post-metadata">

**Author:** ![Alien](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/alien/32/40701_2.png) [@Alien](https://forum.dynamobim.com/u/Alien)\
**Post date:** [November 16, 2022, 3:12pm UTC](https://forum.dynamobim.com/t/if-statement-with-different-outcomes/83174/6 "2022-11-16T15:12:51Z")

</div>

Yep, see my message above!  
Today is one of those days… 🤦 🤦 🤦

How do you put in the list levels in this instance for designscript?

I tried what @Draxl_Andreas suggested… I tried [0] after list and group but neither worked.

---

<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:** [November 16, 2022, 3:14pm UTC](https://forum.dynamobim.com/t/if-statement-with-different-outcomes/83174/7 "2022-11-16T15:14:43Z")

</div>

We’ve all been there. Even so, there is a difference between the methods you’re using. Structure is very important when dealing with condition statements.

---

<div class="post-metadata">

**Author:** ![Alien](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/alien/32/40701_2.png) [@Alien](https://forum.dynamobim.com/u/Alien)\
**Post date:** [November 16, 2022, 3:18pm UTC](https://forum.dynamobim.com/t/if-statement-with-different-outcomes/83174/8 "2022-11-16T15:18:18Z")

</div>

How do I fix it in designscript?

 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/5/0/504fe0390002f050c055056decf8d7ea23a76219.png)

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

I get the same output regardless of if it’s true of false.

lines and groups do have the same items but one is split into groups.

---

<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:** [November 16, 2022, 4:02pm UTC](https://forum.dynamobim.com/t/if-statement-with-different-outcomes/83174/9 "2022-11-16T16:02:53Z")

</div>

If you look closely they are not the same. The false condition returns all the same items (first item in false list) in the structure of the true result.

You just need to use the standard workaround to get the correct output.  
 ![DynamoSandbox_2022-11-16_10-00-45](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/2/7/273da48e6960d1758350a4af8e7711279190a84d.gif)

---

<div class="post-metadata">

**Author:** ![Alien](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/alien/32/40701_2.png) [@Alien](https://forum.dynamobim.com/u/Alien)\
**Post date:** [November 16, 2022, 4:04pm UTC](https://forum.dynamobim.com/t/if-statement-with-different-outcomes/83174/10 "2022-11-16T16:04:59Z")

</div>

Thank you! Designscript really confuses me.

---

<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:** [November 16, 2022, 4:10pm UTC](https://forum.dynamobim.com/t/if-statement-with-different-outcomes/83174/11 "2022-11-16T16:10:55Z")

</div>

The tricky part is that DesignScript doesn’t always have a one-to-one translation for certain nodes. The `If` node and the index shorthand (`list[index]`) are the two most common culprits. This means there’s often a little more involvement when getting them to work “as expected”.
