GeometryBase input parameter recognise as Brep instead of NurbsSurface in a C# Script

Hello all,
I am new to GH Development, coming from other CAD horizons, I am still in discovering modus, but it’s cool I enjoy the tool so far.
And here comes my first question to the forum, I feel a bit sorry about it as it sounds quite trivial, but I couldn’t find any answer here:
I just try to check the type of an object given as a GeometryBase in a C# Script.
The function in the component requires a NurbsSurface or a NurbsCurve, that’s why I set the input typ to GeometryBase and check afterward the real type.
To do that I basicaly test if (inputGeometrie is NurbsSurface) but it always gives false (altough giving a nurbssurface to the component of course). I saw that the given NurbsSurface is somehow seen by the component as a Brep which I can’t cast back into a NurbsSurface.
What disturbs me at most, is that the exact same code with the exact same use case works as expected, if used in form of a C# plug-in (and not a script). And unfortunatly I have to deliver a script. How can it be so?

Any help appreciated! Thanks.

The surface classes in the Rhino SDK are pretty limiting in that they do not allow for trimming information. Hence, what Grasshopper calls surfaces are actually stored as single-face breps. What you have to do is see if your data is a Brep, then see if that brep has only a single face and then see if that face is of type NurbsSurface. Although you can always convert any surface type to NurbsSurface so you may as well call the conversion method right away.

Hello David, thank you for the quick response, it solved the problem.
So you mean as NurbsSurfaces can’t be trimmed, they are stored per default as BrepFace by the creation in Rhino, so that they as such gain the trim ability, am I right?

But how come does the problem appear in a script and not while debugging in VisualStudio?

I think so. Surfaces are used to make Breps, but almost never used directly in the Rhino or Grasshopper documents.

Before data is handed to a script it is converted into a ‘safe’ instance which can be modified without affecting data elsewhere, it may be that in this process something introduces a significant difference between compiled and scripted components.