# Empty List to Value

Hi, I’m trying to subtract window areas from wall areas and whenever there isnt a window within a wall, it returns an empty list, which doesn’t work in subtracting formula a-b = c, where a = wall area, b = window area.

I suppose a python if else statement might work here, but I don’t know how to formulate the question. If b == 0? If b== real? I also tried using List.isEmpty, and packages but nothing seemed to work

I’m sure there is a very simple answer and I’m clearly doing something wrong.

Use a List.IsEmpty and a List.FilterByBoolean to take out all of the empty walls. The. You can do the math of the ones that contain windows, and put a “0” in the ones that don’t.

Hey,

Just for completeness, @Andreas_Dieckmann also posted a solution to a similar sounding question…

Hopefully that’s useful,

Mark

1 Like

One other method is to look at the number of items in the list at level 2, test if the count is equal to zero. if the test is true, return a 0, otherwise it return null.

That value at level 1 is then added to the lists at level 2 (effectively sliding a 0 or a null into the front of each sub list), and finally the list is cleaned without preserving indices (meaning null and empty lists are discarded, so the null values which are added are dropped but the added zeros are maintained).

This is a handy custom node to build and add to your library (using an input as the replacement as you may not always want a 0).

Hi @Mark.Ackerley, thank you its a solid suggestion, however it won’t work in my case, as I’m taking element curve segments as my lengths. There are walls spanning over a couple of rooms, hence can’t measure wall surface areas per room.

1 Like

Hi @SeanP, putting a 0 in the ones that don’t is exactly what I’m trying to do. I do however, already have the lists filtered the way I need them to be. The issue is, that I either have some values, or have none. When I have none, the question is how to call this a 0. Can you elaborate on how to put a “0” in the ones that don’t?

Thanks,

Hi @jacob.small, this seems to be a good idea, but I’m having troubles implementing. Could you post an example, please?

So far I got there:

Many thanks,