How to determine if a feature class is an annotation feature class?

174
2
06-23-2021 08:21 AM
Labels (2)
HannahBernal
New Contributor II

Hello,

For the ArcGIS Pro SDK, is there a way to determine if a feature class is an annotation feature class? I had attempted to do this with an annotation layer but it didn't work:

var annotation_ftr_class = feature_class as AnnotationFeatureClass; // returns null

I know that for the ArcObjects SDK, the IFeatureClass.FeatureType property can be used to get the esriFeatureType. And if it's an esriFTAnnotation, it is considered an annotation feature.

Is there something equivalent that can be used for the ArcGIS Pro SDK?

Thank you,

Hannah

2 Replies
Waffle_House
Occasional Contributor

Have you tried something like this from this page

if (selectedLayer is ArcGIS.Desktop.Mapping.AnnotationLayer)

 

0 Kudos
HannahBernal
New Contributor II

Thank you for your response. Since I only have the layer_name available, I did try these two methods:

using (Table table = geodatabase.OpenDataset<Table>(layer_name)) {
FeatureClass feature_class = table as FeatureClass;
// attempt 1:
if (feature_class is AnnotationFeatureClass) {
// feature class is annotation feature class
}

// attempt 2:
AnnotationFeatureClass annoFtrClass = geodb.OpenDataset<AnnotationFeatureClass>(layer_name);
if (annoFtrClass != null) {
 // is annotation feature class
}

 But neither way worked. The second method would throw this exception: Could not open the dataset 'annotation_layer' as type AnnotationFeatureClass. Please make sure the dataset type is correct. 

0 Kudos