AnsweredAssumed Answered

ArcGIS Help 10.1 - Creating a Python add-in button. This is not working for me, please help.

Question asked by spencerlank on Nov 24, 2014

Hello,

 

I'm following a tutorial here: ArcGIS Help 10.1

 

I have added the code to the .py file and installed the add-in in using the makeaddin.py file and Test001.esriaddin file yet when I press the button, nothing happens. It's supposed to zoom to the selected features. I have ArcMap 10.2 and indicated so in the Python Add-In Wizard provided by ESRI. Attached is the .py file, . Here is the code:

import arcpy

import pythonaddins

 

 

class ZoomToSelectedFeatures(object):

    """Implementation for Test001_addin.btn1 (Button)"""

    def __init__(self):

        self.enabled = True

        self.checked = False

       # Implementation of OnClick method of Button's class

       def onClick(self):

            # Get the current map document and the first data frame.

            mxd = arcpy.mapping.MapDocument('current')

            df = arcpy.mapping.ListDataFrames(mxd)[0]

            # Call the zoomToSelectedFeatures() method of the data frame class

            df.zoomToSelectedFeatures()

Thank you in advance for taking the time to help.

Outcomes