I am attempting to remove all Annotation Subclass layers from a list that is generated from a Map inside of ArcGIS Pro. From what I can tell the subclasses must be a "Layer" inside of Pro.

I cannot find a method to conclusively distinguish which layers are annotation subclasses.

l = [list of Layer Objects]
for x in l:
    if x:
            desc = arcpy.Describe(x)
            print (desc.featureClass.featuretype)
            print (f"{x} cannot be described")

This will yield "Annotation" for both the Annotation layer, and its subclasses.


This will yield the Name of the Annotation layer for all subclasses

for x in l:
    print (x)

generates an error NameError: The attribute 'longName' is not supported on this instance of Layer as soon as it hits the Annotation subclass

  • Welcome to GIS SE! As a new user please take the tour. Please edit your question to include a snippet of the code you've tried and details of the result when you run it. Explain what you mean by "the properties... for the subclasses are odd" – Midavalo Jul 2 at 14:30

You could use a process of elimination to determine whether your annotation layer is a subclass or not. The Annotation layer itself will return a True if you query isFeatureLayer, but on the subclass it will error.

Now I'm not a fan of using try and except to determine values, but in this case you could catch that error to determine which layer is the subclass.

for layer in layers:
    desc = arcpy.Describe(layer)
    if desc.featureType == "Annotation":
            if layer.isFeatureLayer:
                x = "Annotation Class Layer"
            x = "Annotation Subclass Layer"

gives the result

'My Annotation'
Annotation Class Layer
'Class 1'
Annotation Subclass Layer
'Class 2'
Annotation Subclass Layer
| improve this answer | |
  • Thanks for this. I have more or less done the same thing, using different properties that the Subclasses dont happen to have. my concern is that this doesnt explicitly find the subclasses which would be ideal. – David Metzler Jul 2 at 17:49

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.