In ArcCatalog, getting the properties on an Annotation Feature Class exposes an Annotation Classes tab and within that is a list of the names of the associated annotation classes.

Assume an MXD with a feature-linked annotation layer and another layer with the associated source feature class, both stored in SDE. Can someone provide some code that will get that list of annotation class names? I've been searching through the documentation with no success. I'm using C#.


Okay, I figured it out. Here is some code.

(In this example, the Annotation Feature layer was previously stored in m_FLayer and the names of the classes are written to a checked list box on a form.)

            frmShowAnnoClasses theForm = new frmShowAnnoClasses();

            IAnnotationLayer pALayer = (IAnnotationLayer)m_FLayer;
            IAnnotationClassExtension pAnnoClassExtension = (IAnnotationClassExtension) m_FLayer.FeatureClass.Extension;
            IAnnotateLayerPropertiesCollection pAnnoLayerPropsCollection = pAnnoClassExtension.AnnoProperties;
            IAnnotateLayerProperties pAnnoLayerProps = null;
            IElementCollection pElementCollection_Placed = null;
            IElementCollection pElementCollection_UnPlaced= null;
            for (int x = 0; x < pAnnoLayerPropsCollection.Count; x++)
                pAnnoLayerPropsCollection.QueryItem(x, out pAnnoLayerProps, out pElementCollection_Placed, out pElementCollection_UnPlaced);
                theForm.clbAnnoClass.Items.Add(pAnnoLayerProps.Class, true);


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.