This simple script removes nulls from a list in Grasshopper. It preserves all data types and other data that you pass through it.
To set up, copy the code below into a standard C# component in Grasshopper. Set input x as a list. Feed your list into x. The return ‘A’ will return the list x with nulls removed.
var rtnlist = new List<object>(); foreach (object obj in x) { if (obj != null) rtnlist.Add(obj); } A = rtnlist;
The other C# (counting nulls) in the image came from this post.