RhinoCommon C# Recognize ObjectType

Hi,

this is a pretty basic question, but what would be the easiest option to recognize the ObjectType? (using RhinoObject or ObjRef as input)?

I don`t see anything in the Attributes…I could check for every possible type:

var curve = gc.Object(i).Curve();
if (null != curve)
I guess I have a curve

But that seems a bit much…?

Thanks!

RhinoObject has an ObjectType property that reveals objects ObjectType enum. If you’re prompting the user to pick some objects its often less effort to setup a geometry filter on the GetObject so that you can easier filter and inspect the results.

https://developer.rhino3d.com/api/RhinoCommon/html/P_Rhino_DocObjects_RhinoObject_ObjectType.htm

1 Like

Hi @dimcic

The as keyword is very useful.

https://github.com/mcneel/rhino-developer-samples/blob/6/rhinocommon/cs/SampleCsCommands/SampleCsClassifyCurve.cs

– Dale