Empty List Python

Hello everyone,

i am creating a dynamo script to move my electrical drawpit to correct elevation according to Topo.
when topo is covering all the pits, everything is fine but when any pit is outside topo for Point.Project it returns empty list. So i thought to do it through Python. where i am not an expert.
idea is in case point.Project returns empty list, it should be replaced with its own location.
need help to achieve this objective.

any suggestions.

Thanks in Advance.


Using an additional List.Flatten node should remove all empty lists and leave you with a single list of points. Otherwise, you can use a simple test like if len(pits) > 0: before your for loop. In its current state, your variable pit will still be a list itself consisting of a single element, so you will have to index it like p = pit[0] or something similar.

1 Like

Thanks @cgartland
your suggestion worked for me. I added a “if” with List.Count and it worked very well. thanks again.

1 Like