Calculate only if not empty

Hi, my brain is failing this morning. How can I get round this error? My script fails when it encounters an empty value in a tree. I don’t want to invent values to fill it - I just want the script to ignore that line.

Member Index gives me a list of indexes with Empty values - but I can’t find a way to then make use of that knowledge…

Which value do you expect as output for the <empty> ?
You could try a Replace Items with a 0 using the indices from Member Index.

2 Likes

Thanks, that’s a very fair question, and possibly why I’m drawing a blank. I was hoping to only pass the useful data yet keep the Index numbers as they are - but obviously it needs to put something there. Thank you - I think that’s enough of a clue. I guess need to make a shorter list and lose the original Indexes, but still keep a record of them somewhere.

So a following question - if I have my list of Indexes which contain Empties, how can I easily get an inverse of that list? (So in the example below, the opposite list would be 1,2,3,6,9,etc).

Thank you, this looks promising too :slight_smile:

Could not think of an easy way with native components. Here is with python:
include_i = [i for i in range(len(my_list)) if i not in exclude_i]
invert indices.gh (4.1 KB)
image

1 Like

Thanks all, I went with HS_Kim’s answer in the end - seemed simpler, especially as I didn’t need to recombine the data in the end.