# List.IsEmpty returns different length than orginal list

**URL:** <https://forum.dynamobim.com/t/list-isempty-returns-different-length-than-orginal-list/20341>\
**Category:** Uncategorized\
**Created:** [March 22, 2018, 7:45pm UTC](https://forum.dynamobim.com/t/list-isempty-returns-different-length-than-orginal-list/20341 "2018-03-22T19:45:01Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![pieter](https://avatars.discourse-cdn.com/v4/letter/p/82dd89/32.png) [@pieter](https://forum.dynamobim.com/u/pieter)\
**Post date:** [March 22, 2018, 7:45pm UTC](https://forum.dynamobim.com/t/list-isempty-returns-different-length-than-orginal-list/20341/1 "2018-03-22T19:45:01Z")

</div>

Hey,

I’m trying to replace the “empty list” values in my original list with the first non-null value of that same list.

I’ve tried all the suggested solutions on the forum but keep on running into problems.

When I create a bool mask that checks whether a given index is empty, the resulting list is 11 indexes longer than the original list, which results in a “list mismatch” error when using it in the List.MergeByBoolMask.

 ![dynamo%20list%20problem](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/f/f/ff88c378a2e07b0c869417f53ac1cf822824863e.JPG)

---

<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:** [March 22, 2018, 7:52pm UTC](https://forum.dynamobim.com/t/list-isempty-returns-different-length-than-orginal-list/20341/2 "2018-03-22T19:52:14Z")

</div>

Empty Lists are not included in the item count, so I’m guessing you have 190 items/lists and 11 Empty Lists.

---

<div class="post-metadata">

**Author:** ![pieter](https://avatars.discourse-cdn.com/v4/letter/p/82dd89/32.png) [@pieter](https://forum.dynamobim.com/u/pieter)\
**Post date:** [March 23, 2018, 7:32pm UTC](https://forum.dynamobim.com/t/list-isempty-returns-different-length-than-orginal-list/20341/3 "2018-03-23T19:32:44Z")

</div>

Thanks!

Does anyone have any suggestions on how to replace the empty lists with a constant value?

What I’m trying to do with this script is the following:

1 - grab some Revit geometry (easy)  
2 - explode it to its faces (easy)  
3 - grab the material from each face (some python needed)  
4 - then combine all the faces with the same material in one object (easy…as long as the list from 2 and 3 are the same length!)  
5 - write a separate .sat export for each unique material. (easy)

In the end, I would bring in each .sat separately in Formit. Because each .sat is grouped on import, I would have an easier time reassigning the materials.

However, I got stuck at step 3.

When I convert the Dynamosurfaces to Revitfaces (using the Revitface.FromDynamoSurface node), I sometimes get an “empty list” as result.

The problem is, I can’t just drop the emptylists as I want to combine the list from step 2 (geometry) with the list from step 3 (materials) and they need to be the same length for that to work properly.

Anyone any idea how to replace nested “empty lists” with something else?

---

<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:** [March 23, 2018, 8:01pm UTC](https://forum.dynamobim.com/t/list-isempty-returns-different-length-than-orginal-list/20341/4 "2018-03-23T20:01:20Z")

</div>

List.ReplaceEmptyList from Clockwork will replace empty lists with a constant value.

However, if step 2 returns an empty list, step 3 should also return a null/empty list as it won’t have any material, so your lists should match in the end - unless your python code is cleaning up or skipping empty lists. You can probably get around this just by changing how your python code handles empty lists.

---

<div class="post-metadata">

**Author:** ![pieter](https://avatars.discourse-cdn.com/v4/letter/p/82dd89/32.png) [@pieter](https://forum.dynamobim.com/u/pieter)\
**Post date:** [March 23, 2018, 8:21pm UTC](https://forum.dynamobim.com/t/list-isempty-returns-different-length-than-orginal-list/20341/5 "2018-03-23T20:21:12Z")

</div>

Hey Nick,

Thanks for your reply.

The empty lists only appear after converting the dynamo faces to Revit surfaces. Apparently it has some faces don’t have a Revit equivalent. However, I don’t want to drop these faces as it might break some solids (which I really want to keep intact for later use in Formit).

I tried the List.ReplaceEmptyList but I couldn’t get it to work on a nested list. Am I doing something wrong here?

 ![replaceemptylist](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/6/1/612f063c63ef6bc625050eb91b7b6041e9cbd557.JPG)

---

<div class="post-metadata">

**Author:** ![Nico\_Stegeman](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/nico_stegeman/32/19204_2.png) [@Nico\_Stegeman](https://forum.dynamobim.com/u/Nico_Stegeman)\
**Post date:** [March 23, 2018, 8:29pm UTC](https://forum.dynamobim.com/t/list-isempty-returns-different-length-than-orginal-list/20341/6 "2018-03-23T20:29:00Z")

</div>

Try list levels

---

<div class="post-metadata">

**Author:** ![Nico\_Stegeman](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/nico_stegeman/32/19204_2.png) [@Nico\_Stegeman](https://forum.dynamobim.com/u/Nico_Stegeman)\
**Post date:** [March 24, 2018, 6:16am UTC](https://forum.dynamobim.com/t/list-isempty-returns-different-length-than-orginal-list/20341/7 "2018-03-24T06:16:57Z")

</div>

![ReplaceEmptyList](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/3/8/38394dc47f819a54709772efd1ecbc357bfd2e7e.png)

---

<div class="post-metadata">

**Author:** ![pieter](https://avatars.discourse-cdn.com/v4/letter/p/82dd89/32.png) [@pieter](https://forum.dynamobim.com/u/pieter)\
**Post date:** [March 26, 2018, 2:09pm UTC](https://forum.dynamobim.com/t/list-isempty-returns-different-length-than-orginal-list/20341/8 "2018-03-26T14:09:58Z")

</div>

That worked!

Thanks from me and my colleagues for your time Nico and Nick! We appreciate it.

---

<div class="post-metadata">

**Author:** ![pieter](https://avatars.discourse-cdn.com/v4/letter/p/82dd89/32.png) [@pieter](https://forum.dynamobim.com/u/pieter)\
**Post date:** [March 26, 2018, 3:21pm UTC](https://forum.dynamobim.com/t/list-isempty-returns-different-length-than-orginal-list/20341/9 "2018-03-26T15:21:40Z")

</div>

Ok, I had to add another level to the lists in order to support different categories. And now my replaceemptylists node is not working again!

Anyone any ideas?

 ![empty%20lists](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/a/3/a329de6d44b999b9a3acbd1c6ffe536a1969b533.JPG)

---

<div class="post-metadata">

**Author:** ![Nico\_Stegeman](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/nico_stegeman/32/19204_2.png) [@Nico\_Stegeman](https://forum.dynamobim.com/u/Nico_Stegeman)\
**Post date:** [March 26, 2018, 3:42pm UTC](https://forum.dynamobim.com/t/list-isempty-returns-different-length-than-orginal-list/20341/10 "2018-03-26T15:42:44Z")

</div>

set level on @L3

and if you want 4 levels then connect a list.create node after List.ReplaceEmptyList

---

<div class="post-metadata">

**Author:** ![Nico\_Stegeman](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/nico_stegeman/32/19204_2.png) [@Nico\_Stegeman](https://forum.dynamobim.com/u/Nico_Stegeman)\
**Post date:** [March 26, 2018, 3:46pm UTC](https://forum.dynamobim.com/t/list-isempty-returns-different-length-than-orginal-list/20341/11 "2018-03-26T15:46:50Z")

</div>

> [@pieter](#):
>
> Ok, I had to add another level to the lists in order to support different categories. And now my replaceemptylists node is not working again!
> 
> Anyone any ideas?
> 
> ![empty%20lists](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/a/3/a329de6d44b999b9a3acbd1c6ffe536a1969b533.JPG)

 ![Capture](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/f/5/f5ac3b939de02a7d48c83b5c3e6a87cbf835b3d8.png)

---

<div class="post-metadata">

**Author:** ![pieter](https://avatars.discourse-cdn.com/v4/letter/p/82dd89/32.png) [@pieter](https://forum.dynamobim.com/u/pieter)\
**Post date:** [March 26, 2018, 4:13pm UTC](https://forum.dynamobim.com/t/list-isempty-returns-different-length-than-orginal-list/20341/12 "2018-03-26T16:13:33Z")

</div>

Thanks that fixed it!
