Convert null to "0"


I just need a way to convert null to 0.

I have a List.Count that gives the number of Sheets that already exist in Revit compared to a list from Excel and I use that number to jump to the new elements on the list. The thing is, the first time you use the script the number of elements is 0 and it gives be back null. But what I would need is actually just the value “0”. Is there a quick way to convert “null” to “0” without installing any packages?

One line of design script should do the trick:

DSCore.List.Count(lst)==null? 0 : DSCore.List.Count(lst);

If the count is null (?) gimme zero ( : ) otherwise gimme the count.

1 Like

Hey, Please try to use “Manage.ReplaceNulls” node.

Hallo honeyjan619, thank for the Info. But as I said, I would prefer that no Packages are involved. The thing is the script would be use by many people in the company and it should work without requiring to install additional Packages.

Null to zero.dyn (27.1 KB)
Hey C.Celles, can you please check this script will work for you or not?

1 Like

Null to zero2.dyn (13.3 KB)

Hello C.Celles, i think i got your solution, replacing null value with zero by using code block.

1 Like

Hmm, this all seems a little bit over the top. Why not do as Jacob says and do a little DesignScript?


Thanks you JacobSamll! That did the trick.

Thankyou @jostein_olsen, its a new learning for me. :innocent: