Best method to loop through Objects to find out what type they are?

I am creating a command to allow user to select a bunch of objects on a plane.

My question is how do I loop through the list of objects as there are many types. At the start, I may just want to handle only Curve and TextEntity.

I use GetObject function to get any objects.

But what I find is do I use the GetType() and compare the type of Object.

Is there a smarter way of looping through the list of Geometry?

GetResult result = go.GetMultiple(1, -1);

         for (int i = 0; i < go.ObjectCount; i++)
            // Check the type of the Object and process differently

            GeometryBase geo = go.Object(i).Geometry();



         foreach (GeometryBase g in geoList)
            else if(g.GetType().Equals(typeof(Curve)))
            else if(g.GetType().Equals(typeof(TextEntity)))


You could use the GeometryFilter to restrict the getter to the types of objects you want the user to select:

@fraguada I understand the geometry filter. My question is more on how do I loop through all the objects and process them.

The question I had was how do I loop through them easily, because when you get object, you don’t know what type it is .

Just for an example, a Curve can be an Arc, an circle, etc.

Hi @TobyLai,

For objects that inherit from GeometryBase, you can use the typeof keyword that you are already using, or query the GeometryBase.ObjectType property.

For testing for curve types, it gets a bit more complicated. Here is an example you might find helpful.

– Dale

Thanks @dale that is exactly what I am looking for.