I am writing an add-in that in one step requires to find all layers that have selections. To achieve that I am using FIDSet property of Describe object. Unfortunately, I get an error: "AttributeError: DescribeData: Method FIDSet does not exist" (why "method" anyway?). While I perform test like this, in Python window in ArcMap:

desc = arcpy.Describe("O_PODST")

Everything works fine, but while using my add-in I get this error. How to make it work? Here is my code:

class ShowParcLU(object):
    """Implementation for Okienko_addin.button (Button)"""
    def __init__(self):
        self.enabled = True
        self.checked = False

    def onClick(self):
        mxd = arcpy.mapping.MapDocument("CURRENT")

        if arcpy.mapping.ListTableViews(mxd, "PARC_LU"):
            layers_with_selections = []

            for i in arcpy.mapping.ListLayers(mxd):
                if len([int(fid) for fid in arcpy.Describe(i).FIDSet.split(";") if fid != '']) > 0:

FIDSet is a Describe property of a feature layer. dataSource will return the full path to a layer's data source. In your code, you want to reference the layer, not its data source, so remove dataSource.

if len([int(fid) for fid in arcpy.Describe(i).FIDSet.split(";") if fid != '']) > 0:

FYI, cleaner code to get what you're after (checking for selection):

if arcpy.Describe(i).FIDSet:
  • You are right, I should reference Layer. I probably even have tried that before... Anyway it is still not working... "RuntimeError: Object: Describe input value is not valid type". However, I tested this add-in in ArcMap 10.3 and it works fine! But I need it working also on 10.2. – Kubson Aug 17 '17 at 8:02
  • OK, so it wasn' t about ArcMap version but about the layers in project... – Kubson Aug 17 '17 at 9:44

The problem lied in layers present in project. One of them was a Raster layer and obviously Describe object created on Raster layer doesn't have FIDset property. I should put an additional If statement in loop over layers preventing this error.

            for i in arcpy.mapping.ListLayers(mxd):
                if i.isFeatureLayer:
                    if arcpy.Describe(i).FIDSet:

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.