Heyhey,
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":
projected_curves.append(prj_crv)
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,
Johannes
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