# "If" node doesn't output an array of values

**URL:** <https://forum.dynamobim.com/t/if-node-doesnt-output-an-array-of-values/30355>\
**Category:** Lists-Logic\
**Created:** [January 7, 2019, 10:01am UTC](https://forum.dynamobim.com/t/if-node-doesnt-output-an-array-of-values/30355 "2019-01-07T10:01:48Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![archjahzzy](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/archjahzzy/32/26144_2.png) [@archjahzzy](https://forum.dynamobim.com/u/archjahzzy)\
**Post date:** [January 7, 2019, 10:01am UTC](https://forum.dynamobim.com/t/if-node-doesnt-output-an-array-of-values/30355/1 "2019-01-07T10:01:48Z")

</div>

Hi all,

I’m sorry if this seems like a very basic question (tried to look for some similar posts but couldn’t find one).

I am trying to use the “If” node to generate different results. In my example, the goal is to delete either CAD Link or Imported Links.

When the user ticks “CAD Imports”, I want the script to delete all imported CAD files generated from Bimorph’s CAD.ReportInstances node.

Problem is, the final “If” node does not get all list values from the previous node - it only takes the first item on the list. I thought I could remedy this with Lacing but If node doesn’t have Lacing property. I tried the Longest Lacing node but not sure what combinator input needs.

Please refer to the snapshot of the script below:  
 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/3/2/3222be661b33ff2c9ad9431b453947a4308750bb.png)

Thank you all!

Jahzeel

---

<div class="post-metadata">

**Author:** ![archjahzzy](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/archjahzzy/32/26144_2.png) [@archjahzzy](https://forum.dynamobim.com/u/archjahzzy)\
**Post date:** [January 7, 2019, 10:08am UTC](https://forum.dynamobim.com/t/if-node-doesnt-output-an-array-of-values/30355/3 "2019-01-07T10:08:12Z")

</div>

Hi all,

Interestingly, adding a “List Create” node to only one of the previous results gives me the list. However, adding them to both gives me only the first item.

Here, I get all items from the list:  
 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/d/f/df122c34cf97abe721b824ec00674cc68ebd38b7.png)

After adding “List.Create” node to both, I get the same issue again:  
 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/7/9/7978e58b44deb5c862e34cd72541f47b6756f951.png)

---

<div class="post-metadata">

**Author:** ![kennyb6](https://avatars.discourse-cdn.com/v4/letter/k/7ba0ec/32.png) [@kennyb6](https://forum.dynamobim.com/u/kennyb6)\
**Post date:** [January 7, 2019, 10:09am UTC](https://forum.dynamobim.com/t/if-node-doesnt-output-an-array-of-values/30355/4 "2019-01-07T10:09:08Z")

</div>

The problem probably has to do with how if node works on different length lists for the true and false values. The [common alternative is ScopeIf](http://dictionary.dynamobim.com/#/Core/Logic/Action/ScopeIf) but it can be a bit trickier.

I don’t remember the exact details but I am sure there are several posts somewhere comparing the two. Some older examples include [IF node](https://forum.dynamobim.com/t/if-node/2271/9) and [If and Lists of different lengths](https://forum.dynamobim.com/t/if-and-lists-of-different-lengths/3669/2)

---

<div class="post-metadata">

**Author:** ![archjahzzy](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/archjahzzy/32/26144_2.png) [@archjahzzy](https://forum.dynamobim.com/u/archjahzzy)\
**Post date:** [January 7, 2019, 10:29am UTC](https://forum.dynamobim.com/t/if-node-doesnt-output-an-array-of-values/30355/5 "2019-01-07T10:29:20Z")

</div>

Hi @kennyb6,

Thank you so much!  
I tried **ScopeIf** and also found that Clockwork also has **ScopeIf+** node.

I tried to use both and found that Clockwork’s node does the job better, and is also faster.

 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/4/2/423d4db1134c3ae1b596099db8a45241bfd6e2a3.png)

The normal **ScopeIf** somehow loads slower, and gives a “null” output to my CAD.ReportInstances node (didn’t know a proceeding node could affect the nodes that precede it). I tried to test it several times… I guess it’s not stable enough?

Anyway, thank you so much for introducing me to this node 🙂

---

<div class="post-metadata">

**Author:** ![Jean-Marc](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/jean-marc/32/79122_2.png) [@Jean-Marc](https://forum.dynamobim.com/u/Jean-Marc)\
**Post date:** [January 7, 2019, 12:25pm UTC](https://forum.dynamobim.com/t/if-node-doesnt-output-an-array-of-values/30355/6 "2019-01-07T12:25:52Z")

</div>

You could try the old style if in a code block:

```
choice = {list1,list2};
choice[x ? 0 : 1];

```

which will never disappoint 😉

---

<div class="post-metadata">

**Author:** ![Mark.Ackerley](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/mark.ackerley/32/79310_2.png) [@Mark.Ackerley](https://forum.dynamobim.com/u/Mark.Ackerley)\
**Post date:** [January 7, 2019, 4:26pm UTC](https://forum.dynamobim.com/t/if-node-doesnt-output-an-array-of-values/30355/7 "2019-01-07T16:26:24Z")

</div>

Hey,

I agree with you in using Clockwork ScopeIf+, which I believe contains a version of Jean-Marc’s solution.

As you’re finding you need to be careful with the OOTB ScopeIf, it is designed to be used within custom nodes…

> [@Simple If ... acting up on Friday morning](https://forum.dynamobim.com/t/simple-if-acting-up-on-friday-morning/21445/9):
>
> scope if is a tricky node, the two branches must be totally independent, but it is very useful - it actually will not execute the branch that is not passed through. This is unlike all other nodes in Dynamo, it’s valuable when your branches have side effects like interacting with revit.

I had graphs freeze because the unexecuted branch was being used for other nodes downstream (say you wanted a dated folder inside an undated folder, but not having the first one dated you can accidentally freeze the second create node and the whole thing stops).

Hope that’s of interest,

Mark

---

<div class="post-metadata">

**Author:** ![archjahzzy](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/archjahzzy/32/26144_2.png) [@archjahzzy](https://forum.dynamobim.com/u/archjahzzy)\
**Post date:** [January 8, 2019, 1:49am UTC](https://forum.dynamobim.com/t/if-node-doesnt-output-an-array-of-values/30355/8 "2019-01-08T01:49:20Z")

</div>

Thanks @Jean-Marc.  
I am still a little unfamiliar with some code block notations.  
But thanks for suggesting this as I can study & look it up. 🙂
