# Error Trapping an Empty List

**URL:** https://forum.dynamobim.com/t/error-trapping-an-empty-list/17937
**Category:** Lists-Logic
**Created:** [January 8, 2018, 4:05am UTC](https://forum.dynamobim.com/t/error-trapping-an-empty-list/17937 "2018-01-08T04:05:12Z")
**Posts on this page:** 17
**Page:** 1

<div class="post-metadata">

### Author: ![lheavner48](https://avatars.discourse-cdn.com/v4/letter/l/3ab097/32.png) [@lheavner48](https://forum.dynamobim.com/u/lheavner48)
#### Post date: [January 8, 2018, 4:05am UTC](https://forum.dynamobim.com/t/error-trapping-an-empty-list/17937/1 "2018-01-08T04:05:12Z")

</div>

Hi There,

I have a need to error trap a null set.

I am reading in spreadsheet data that describes the points and profiles for a 3D sweep. There are 2 types of profile that can be used in the sweep. (a circle, and a flat or filleted rectangle) The incoming list can have a mix of designated type or only use one type of profile depending on individual circumstance. Therefore, I choose a Boolean mask to expose the round and flat types.

The problem comes in when one or the other profile type is exclusively chosen for a given design. The boolean mask then returns a “full” list for one type and a empty list for another type. I would like to capture the errors prior to passing on to a node failure. I’m not too sure the node failure is actually a “bad” thing as it’s a failure and no geometry is created. 8^) However, I don’t think it’s a good practice.

please see the node map below and I have added a closer look at the nodes that perform this task. Thanks in advance.

Larry H. ![closeup](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/3/0/30e5b7a51161e307eaded6732f779f1e1cbc3292.jpg) ![Trap Null](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/4/8/4840a04d18cdb945148ffe31eb1b75cddf81c0b0.png)

---

<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: [January 8, 2018, 5:40pm UTC](https://forum.dynamobim.com/t/error-trapping-an-empty-list/17937/2 "2018-01-08T17:40:51Z")

</div>

There’s really not much you can do about it to be honest. Like you said, it’s not hurting anything, and you can’t keep a portion of a graph from running so your best bet is to just leave it as is or do it in Python.

You can always add an output somewhere that explains what is going on if you’re worried about misinterpreting warnings as an error. (Ex: “4 sweeps and 0 circles created.”)

---

<div class="post-metadata">

### Author: ![Michael\_Kirschner2](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/michael_kirschner2/32/75576_2.png) [@Michael\_Kirschner2](https://forum.dynamobim.com/u/Michael_Kirschner2)
#### Post date: [January 8, 2018, 7:03pm UTC](https://forum.dynamobim.com/t/error-trapping-an-empty-list/17937/3 "2018-01-08T19:03:15Z")

</div>

you can keep a portion of the graph from running using a scope if node - it has different rules than the if node though - keep the two branches completely separate.

---

<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: [January 8, 2018, 8:01pm UTC](https://forum.dynamobim.com/t/error-trapping-an-empty-list/17937/4 "2018-01-08T20:01:31Z")

</div>

I don’t think I understand how that would work… You could use ScopeIf to manage the final output but how would you keep part of a graph from running using ScopeIf? It would still have to be evaluated somewhere wouldn’t it?

---

<div class="post-metadata">

### Author: ![Michael\_Kirschner2](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/michael_kirschner2/32/75576_2.png) [@Michael\_Kirschner2](https://forum.dynamobim.com/u/Michael_Kirschner2)
#### Post date: [January 8, 2018, 8:13pm UTC](https://forum.dynamobim.com/t/error-trapping-an-empty-list/17937/5 "2018-01-08T20:13:06Z")

</div>

scope if passes code around, not data, only one of the two input branches is executed, this is why you can use this node to accomplish recursion which is not infinite.

---

<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: [January 8, 2018, 8:26pm UTC](https://forum.dynamobim.com/t/error-trapping-an-empty-list/17937/6 "2018-01-08T20:26:12Z")

</div>

So that’s the difference. That makes a lot of sense. Thanks for explaining that.

---

<div class="post-metadata">

### Author: ![lheavner48](https://avatars.discourse-cdn.com/v4/letter/l/3ab097/32.png) [@lheavner48](https://forum.dynamobim.com/u/lheavner48)
#### Post date: [January 8, 2018, 10:49pm UTC](https://forum.dynamobim.com/t/error-trapping-an-empty-list/17937/7 "2018-01-08T22:49:00Z")

</div>

many thanks for the responses! This may be a really dumb question, but it is perplexing me. How do I test for null? Everything I seem to try makes Dynamo ill. I get how a language that thrives on arrays would throw up when is reads a null set, but I’m not sure how to feed the “test” statement in the Scopedif and the if statement without just plain feeding it null. If there are any examples that can be shared I’d appreciate it.

---

<div class="post-metadata">

### Author: ![awilliams](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/awilliams/32/114496_2.png) [@awilliams](https://forum.dynamobim.com/u/awilliams)
#### Post date: [January 8, 2018, 10:55pm UTC](https://forum.dynamobim.com/t/error-trapping-an-empty-list/17937/8 "2018-01-08T22:55:21Z")

</div>

I think the Object.IsNull node is what you are looking for 🙂

---

<div class="post-metadata">

### Author: ![lheavner48](https://avatars.discourse-cdn.com/v4/letter/l/3ab097/32.png) [@lheavner48](https://forum.dynamobim.com/u/lheavner48)
#### Post date: [January 8, 2018, 10:59pm UTC](https://forum.dynamobim.com/t/error-trapping-an-empty-list/17937/10 "2018-01-08T22:59:36Z")

</div>

Thanks Amy… That’s a good start. While I believe that I’m testing for null. The Boolean Mask returns an “empty list” result. I am assuming that this is null, but not sure. However, it’s well worth trying!

---

<div class="post-metadata">

### Author: ![lheavner48](https://avatars.discourse-cdn.com/v4/letter/l/3ab097/32.png) [@lheavner48](https://forum.dynamobim.com/u/lheavner48)
#### Post date: [January 8, 2018, 11:02pm UTC](https://forum.dynamobim.com/t/error-trapping-an-empty-list/17937/11 "2018-01-08T23:02:34Z")

</div>

I do cleanse the original lists of their many many nulls with success. The issue is that I generate a null “Empty Set” during a Boolean mask operation. This is to be anticipated as some of the data will only have one type of profile type. Other data will have a mixture of profile types so I need to anticipate the error and trap it.

---

<div class="post-metadata">

### Author: ![lheavner48](https://avatars.discourse-cdn.com/v4/letter/l/3ab097/32.png) [@lheavner48](https://forum.dynamobim.com/u/lheavner48)
#### Post date: [January 8, 2018, 11:10pm UTC](https://forum.dynamobim.com/t/error-trapping-an-empty-list/17937/12 "2018-01-08T23:10:09Z")

</div>

Unfortunately, an “Empty List” is not == to null. IsNull does not return a Boolean true or false just “Empty List”. Bummer it was a ray of hope…😥

---

<div class="post-metadata">

### Author: ![lheavner48](https://avatars.discourse-cdn.com/v4/letter/l/3ab097/32.png) [@lheavner48](https://forum.dynamobim.com/u/lheavner48)
#### Post date: [January 8, 2018, 11:14pm UTC](https://forum.dynamobim.com/t/error-trapping-an-empty-list/17937/13 "2018-01-08T23:14:46Z")

</div>

Name updated to Error Trapping an Empty List… Apologies for not being more precise.

---

<div class="post-metadata">

### Author: ![awilliams](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/awilliams/32/114496_2.png) [@awilliams](https://forum.dynamobim.com/u/awilliams)
#### Post date: [January 8, 2018, 11:17pm UTC](https://forum.dynamobim.com/t/error-trapping-an-empty-list/17937/15 "2018-01-08T23:17:17Z")

</div>

> [@lheavner48](#):
>
> Error Trapping an Empty List

Ah then the List.IsEmpty node - this will give you a boolean value for whether or not you have an Empty List which you can use to filter them from your list

---

<div class="post-metadata">

### Author: ![lheavner48](https://avatars.discourse-cdn.com/v4/letter/l/3ab097/32.png) [@lheavner48](https://forum.dynamobim.com/u/lheavner48)
#### Post date: [January 8, 2018, 11:18pm UTC](https://forum.dynamobim.com/t/error-trapping-an-empty-list/17937/16 "2018-01-08T23:18:25Z")

</div>

Huh… My bad I thought that node created an empty list. I may have been looking at the incorrect node.

---

<div class="post-metadata">

### Author: ![awilliams](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/awilliams/32/114496_2.png) [@awilliams](https://forum.dynamobim.com/u/awilliams)
#### Post date: [January 8, 2018, 11:19pm UTC](https://forum.dynamobim.com/t/error-trapping-an-empty-list/17937/17 "2018-01-08T23:19:55Z")

</div>

[http://dictionary.dynamobim.com/#/Core/List/Action/IsEmpty](http://dictionary.dynamobim.com/#/Core/List/Action/IsEmpty) this is the node I’m talking about! You’re referring to List.Empty (very close names lol)

---

<div class="post-metadata">

### Author: ![lheavner48](https://avatars.discourse-cdn.com/v4/letter/l/3ab097/32.png) [@lheavner48](https://forum.dynamobim.com/u/lheavner48)
#### Post date: [January 8, 2018, 11:23pm UTC](https://forum.dynamobim.com/t/error-trapping-an-empty-list/17937/18 "2018-01-08T23:23:15Z")

</div>

Got it! Returns a true. Not sure of what to do with the “true” output of an If statement. I’d like it to feed it to the bit basket, but that’s the next problem. I now need to make sure I untangle any interaction between the profile options and move forward. Code on friends! Code on!🤙

---

<div class="post-metadata">

### Author: ![lheavner48](https://avatars.discourse-cdn.com/v4/letter/l/3ab097/32.png) [@lheavner48](https://forum.dynamobim.com/u/lheavner48)
#### Post date: [February 8, 2018, 7:37pm UTC](https://forum.dynamobim.com/t/error-trapping-an-empty-list/17937/19 "2018-02-08T19:37:14Z")

</div>

Hi Mike and all.

Like all good 🕶 development projects… There have been requirement changes that have forced a rewrite of the duct canvas I’ve been working on. However, I have returned to the point where I do need to conditionally branch based on the duct profile geometry I described above. re:(Rectangular, or Round geometry) I do believe that Scopeif is the right decision because I need to either create one type of profile or another based on the csv file that I now am reading.

Admitting to complete nob-dom, I need some assistance here.

Can anyone share an example of Scopeif moving down one path or another? I have tried Boolean Mask, but because my work examples only contain one duct type or another I land up with an empty set on the “out” branch of the Mask. (error trapping an empty list…) I am even more of a novice at Python, but am willing to modify a code block given some guidance.

 ![CSV_RectRound_branching](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/5/4/54f18d0d7ff29c51d4a540dba265f3df208e8e4b.png)

> [@Michael\_Kirschner2](#):
>
> passes code around

 ![Branch%20Location](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/a/2/a21e5cdcdf39fe09c8a36482f0e64e783619f406.PNG)

I’m not married to the branch location, but it seemed logical and I do want to keep this geometry generation separate.

Finally, the DanEDU package makes quick work of irritating nulls in my lists. GREAT JOB!

Larry H
