Filter a list that has values by index


#1

Forgive me as this might be a really simple solution but i am not able to solve it. Is there a way to filter a list and get the index value of what has data and what does not? Here is an example list I am looking at. Not sure if it matters, but this is a Geometry.Intersect node result. Here is a screen shot of this node. I want to get the indexes of elements that intersect the structure so I can set parameters for just these.

image


#2

You could use List.IsEmpty and List.AllIndicesOf like so:


#3

Thanks Amy!!! I knew there was an easy solution… moving forward now with my script


#4

Follow up to this… that works for an “Empty List” but now do i get same the information(indexes that contain data) if the list is “Null”
image


#5

Use the List.Clean OOTB node. By looking at your image, you might need to use list levels.


#6

Renzoj14
I tried that and I can get to the indexes that have values, but I am looking to find the indexes that contain values so i can sort another list by this index number. I think it is failing because as Amy suggested above, use the list.isempty does not know what to do with the “null” values. Is there another node that will do this?

image


#7

Dose Object.IsNull help?


#8

Steven
I tried that as well. Still cannot get what i need. I need a way to get the index of any element that has coordinates, so in the case above, I need to filter this list and get index 7. The original solution Amy provided above worked until my list started getting “null” values in it, and now it fails.


#9

I feel like there might be a simpler way, but maybe not without Python or a package custom node :thinking: works though ¯\_(ツ)_/¯


#10

Maybe share your script? i’d like to understand why list returns in such manner.


#11

Amy solved it again!! Two in a row today. Thank you Amy.
Renzoj14

It is from a Geometry.Intersect Node and some elements don’t intersect, so I get “null” and “empty list” values… not sure exactly why