How can I check for "type" in IronPython?

I’m writing a little script to project a bunch of curves onto surfaces. I’m determining the projection vector from the bounding box, and checking the normals to find out whether I’m projecting onto the “front” or the “back” of a surface. Only curves projected on the front will then be appended to my list of resulting curves. This all works.
When the curves and the surfaces become more complex, there is sometimes an object of the type “Point” generated by

prj_crv = ds.Surface.ProjectInputOnto(s, crv, vec)

I wanted to filter that using something like

if type(prj_crv) == "NurbsCurve":

As you surely know, type() doesn’t work the way I expected it to, and now I’ve been trying out different variations of the idea using Object.Type(prj_crv), prj_crv.GetType and isinstance().

So far, no success, because even the most promising of these approaches (Object.Type()) returns “Autodesk.DesignScript.Geometry.Geometry” which as far as I know is a .NET array and could contain either Points or NurbsCurves. If I cast it to a list using
prj_crv = list(ds.Surface.ProjectInputOnto(s, crv, vec))
and then try to get the Object within the list with prj_crv[0], I get Index-errors.

I think I lack the understanding of what actually happens to the Array when it is being cast to a list, and why I can’t then select the Object within the list to check for type.

Can someone help me out?
Thanks and best regards from Berlin,


TLDR: How can I test whether

prj_crv = ds.Surface.ProjectInputOnto(s, crv, vec)

results in a NurbsCurve and not a Point in Python with Dynamo for Alias

See if this helps.


Hey Sean,
thank you for replying. I should’ve mentioned, I’m on Dynamo for Alias. It’s possible that your solution still applies, but I can’t tell as I don’t recognize the Assemblies. Are you checking for a type somewhere?

EDIT: ah, I saw the Element.GetTypeId()… don’t know if I have that. I never know what you Revit guys mean by “elements” :smiley:

Try getting the length of the resulted projection.

Hi @cutmeat,

Try this to filter the points :

if isinstance(obj,geom.Point) should maybe be replaced by if not isinstance(obj,geom.Point)

Hey Alban,
thanks for the reply!
I have it set up like in your example:

import Autodesk.DesignScript.Geometry as ds

prj_crv = ds.Surface.ProjectInputOnto(s, crv, vec)
if isinstance(prj_crv, ds.NurbsCurve):

but my resulting list stays empty… Does it have to do with the fact that the result of ProjectInputOnto() is an Array? If so, how do I get to the sweet NurbsCurve inside?
Or is there another error that I don’t see?

I also tried Jacobs solution:

import Autodesk.DesignScript.Geometry as ds

prj_crv = ds.Surface.ProjectInputOnto(s, crv, vec)

if prj_crv.Length > 0:

pt = ds.Curve.PointAtParameter(prj_crv[0], 0.5)

But I still get the same error from before I was even testing for anything, length or type:

File "<string>", line 76, in <module>
TypeError: expected Curve, got Point

As you can see, in the second example I am using prj_crv[0] to create the point. That is the line that gives the error. If I directly check this first item at the index, then if prj_crv[0].Length > 0: I get an “index out of range: 0” error…

EDIT: Possible solution found:
if prj_type[0] == ds.NurbsCurve:
except IndexError:

Thanks everyone!