Remove Nulls in List

I’m trying to remove Nulls from a list with the clean list node but I can’t figure out whats wrong here?

Help very much appreciated!

Thx Rickard

Clear list from archilab

if you want to have same sequence , try use IsEmpty node before math.sum and filter the values, in order to apply Math.sum on only the value that have a numbers

Thanks for helping!
I like to try this without any packages, with that said I don’t really understand how to use the IsEmpty node. Can you please explain a little more?
I’ve also attached the DYN file

Hus A Total.dyn (7.4 KB)

set lacing in List.IsEmpty to longest

I still got 14 false values? :thinking:

@Reklund I was able to replicate your error. Try the following

1 Like

Like This
empty values replaced by zeros so that the sum will not effected with them

Hello guys!
Both ways work perfectly! Thank you so much!

khuzaaimah.ElecEng: This makes sense to me, I understand this :slight_smile:

Salvatoreredragotta: It’s working perfectly, but I can’t understand why, care to explain? If not, thank you again. I appreciate the help!

  • Rickard
1 Like

Your list has empty strings at the end.


The List.Clean node doesn’t remove those. So you’ll have to replace empty strings with null, using conditional (similar to IF in revit formula) in a code block node:

item!="" ? item : null

!= mean does not equal.
"" and empty string

Why are you doing a check “if area is empty” rather than cleaning up your list?

Would it be more clear to just do that (removing nulls from list?) (in my case index 51).

Python script would be:

input = IN[0]
OUT = filter(None, input)

I agree with @3Pinter clean up before instead of at the end. Here is another solution

Do you have idea how to change sort direction, from max to min without deleting to take first (max) item of the list?

I don’t see how the topic title matches your actual question.

To answer the question;
I would remove the first itme item from the list (there is a node for that. Then sort the new list (there is also a node for that) and then combine that list again with the first item from the very first list again.

There is also a node that removes nulls from a list.

Hi @Laura420 ,

Please consider creating another topic with your problem.

The gool is to filter the surface with the bigest area, I know how to fix this problem,“SortByKey” seems to me like a good alternativeI to compres my script.

Ok, it is solution “Clear List” from “archilab” Package

Empty “Input” make warning at launching script I tried to modify “Clear List” and it’s work