Selecting a range of values from a list

I have a list that contains empty values, alphanumerical values and only numerical values. I would like to filter out alphanumerics and blanks and choose only numerical values, preferably in a given range (i.e. 1-272).
I tried this method, but apparently testing agains a blank value “” doesn’t work.

Are all values stored as strings? If not, then the Numbers can be filtered by their System type.

If the values are all strings, then an additional step is necessary.

Then for your range condition…

3 Likes

the Python script gives me an error - as I do not know Python, I am not sure what it means

Paste the below code into a new Python node. :wink:
(Instead of the Python Script from String node)

import clr
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *

clr.AddReference('RevitAPI')
from Autodesk.Revit.DB import *

clr.AddReference('RevitNodes')
import Revit
clr.ImportExtensions(Revit.GeometryConversion)

def tolist(obj1):
    if hasattr(obj1,'__iter__'): return obj1
    else: return [obj1]
    
data=tolist(IN[0])
result=[]

for d in data:
	p1=str(d.GetType())
	result.append(p1)

OUT = result
1 Like

Thank you, it works. My values were all strings, so I did what you have shown in the second image. Thank you!

1 Like