How can I replace each empty list with an value of zero?

Hi,

How can I replace each empty list with an value of zero?

I have a routine that measures the areas. In case of an empty list I need to replace this emptiness with a value of zero. How to do this?

EmptyList .gh (311.1 KB)

Cheers, Bas

In this case i think it makes more sense to code it like this rather than try an insert 0 into an empty list. Here we split the branches so the null values get replaces with 0 and the others create surfaces and calculate are then are merged back together into the main tree.

EmptyList MG.gh (336.3 KB)

1 Like

Hello Bas,
How about something like this:

5 Likes

Thanks a lot. I used this solution.

With Python, you could just use:

if x:
    a = x
else:
    a = 0
4 Likes

This is my final solution. A combination of the two GH answers:
EmptyList MG_ResultBG.gh (128.3 KB)

1 Like