Select to view content in your preferred language

How to get the FeatureType of a FeatureClass

633
3
06-03-2020 05:40 AM
EvaSchuh
New Contributor

I am trying to programmatically get the FeatureType of a FeatureClass with the ArcGIS Pro SDK.

More precisely I would like to find out if the FeatureClass is of type Annotation.

I already tried opening the definition of type AnnotationFeatureClassDefinition.

This does not work (returns null):

Geodatabase.GetDefinition<AnnotationFeatureClassDefinition>("myAnnotation")

I can get the FeatureClassDefinition: 

Geodatabase.GetDefinition<FeatureClassDefinition>("myAnnotation")

But how do I get the FeatureType? 

I am using ArcGIS.Core/ArcGIS.CoreHost in a standalone application.

Does anybody know how to do this?

0 Kudos
3 Replies
RichRuh
Esri Regular Contributor

If you're starting from a FeatureClass object, just try to cast it to an AnnotationFeatureClass:

FeatureClasss myFeatureClass;
...
if (myFeatureClass is AnnotationFeatureClass)
{
  AnnotationFeatureClass myAnnotationFeatureClass = myFeatureClass as AnnotationFeatureClass;
  ...
}

Is this what you are looking for?

--Rich

0 Kudos
EvaSchuh
New Contributor

Thanks, Rich. I was testing with Annotation-FeatureClasses created with ArcGIS Desktop 10.5. 

I now have an Annotation-Featureclass created with ArcGIS Pro and I can either get the AnnotationClassDefinition directly or cast FeatureClass into AnnotationFeatureClass.

0 Kudos
RalfSchmidt
New Contributor III

Hi Rich,

I just ran into this thread with a similar question. Your answer is valid for the OP's question but in my case I need to get the names of all annotation feature classes in the GDB. Here, your approach would mean that I have to hydrate each FeatureClass only to find out if it is an AnnotationFeatureClass or not.

As there are no alternatives, I will go for that.

However, maybe you guys can add an "IsAnnotationFeatureClass" property to the FeatureClassDefinition object, or – even better – make   Geodatabase.GetDefinition<AnnotationFeatureClassDefinition>("myAnnotation")   and   Geodatabase.GetDefinitions<AnnotationFeatureClassDefinition>()   work.

0 Kudos