Test the type of geometry

In python it may actually work faster than to convert to some text showing the type name and then testing on that. You could do the same thing there, but there’s a better alternative.

Standard python comes with the isinstance function. As an example:

In that the Python Code:

import clr
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *
#The inputs to this node will be stored as a list in the IN variables.

#Assign your output to the OUT variable.
OUT = map(lambda val: isinstance (val, Point), IN[0])

Notice I’m using the map function to run across the input list. And I’m sending it a function I write directly there as a lambda. I could have done it this way instead:

import clr
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *
#The inputs to this node will be stored as a list in the IN variables.

def isPoint (val):
    return isinstance (val, Point)

#Assign your output to the OUT variable.
OUT = map(isPoint, IN[0])\

Otherwise I could also used a more imperative way to loop over the values, generating a new list. E.g.:

import clr
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *
#The inputs to this node will be stored as a list in the IN variables.

result = list()
for val in IN[0]:
    result.Add(isinstance(val, Point))

#Assign your output to the OUT variable.
OUT = result
1 Like