In an effort to try to add user input to my project, I'm developing an esri python addin to generate rectangles to my map. I'm on step one now, just exploring the addin functionality.
I tried making an addin 'tool' precisely per the ESRI sample code, but the button isn't working. It appears on my ArcMap desktop, but when I click it, nothing happens.
I just really want to know what's happening with the onRectangle, and how I can get it to accept user input.
Here's the sample code that I essentially stole from ESRI:
import arcpy
import pythonaddins
class fishnetsExample(object):
def __init__(self):
self.enabled = True
self.cursor = 3
self.shape = 'Rectangle'
def onRectangle(self, rectangle_geometry):
"""Occurs when the rectangle is drawn and the mouse button is released.
The rectangle is a extent object."""
extent = rectangle_geometry
# Create a fishnet with 10 rows and 10 columns.
if arcpy.Exists(r'in_memory\fishnet'):
arcpy.Delete_management(r'in_memory\fishnet')
fishnet = arcpy.CreateFishnet_management(r'in_memory\fishnet',
'%f %f' %(extent.XMin, extent.YMin),
'%f %f' %(extent.XMin, extent.YMax),
0, 0, 10, 10,
'%f %f' %(extent.XMax, extent.YMax),'NO_LABELS',
'%f %f %f %f' %(extent.XMin, extent.YMin, extent.XMax, extent.YMax), 'POLYGON')
arcpy.RefreshActiveView()
return fishnet