def onRectangle(self, rectangle_geometry): pythonaddins.MessageBox("Add-In executed!")
Solved! Go to Solution.
import arcpy import pythonaddins class GrabExtents2ToolClass(object): """Implementation for GrabExtents2_addin.tool (Tool)""" def __init__(self): self.enabled = True self.cursor = 3 self.shape = 'Rectangle' def onMouseDown(self, x, y, button, shift): pass def onMouseDownMap(self, x, y, button, shift): pass def onMouseUp(self, x, y, button, shift): pass def onMouseUpMap(self, x, y, button, shift): pass def onMouseMove(self, x, y, button, shift): pass def onMouseMoveMap(self, x, y, button, shift): pass def onDblClick(self): pass def onKeyDown(self, keycode, shift): pass def onKeyUp(self, keycode, shift): pass def deactivate(self): pass def onCircle(self, circle_geometry): pass def onLine(self, line_geometry): pass def onRectangle(self, rectangle_geometry): pythonaddins.MessageBox("Add-In executed!")
With regards to double-clicking the esriaddin file and it asking you which program to open with it sounds like there is a file association problem. Go ahead and right-click any esriaddin file and select Open With > Choose Default program and select ESRIRegAddIn.exe from C:\Program Files\Common Files\ArcGIS\bin.
With regards to the tool. It probably won't make a difference to the problem but go ahead and remove all the other functions in the tool you don't plan to implement, ie onMouseDown, onMouseUp, etc.
The behavior that controls whether you can click and drag and what shape is drawn is controlled by the shape property of the tool class. I see you have it set to Rectangle, so that seems correct. Try adding the same logic to onMouseDown and see if that even causes a messagebox to be shown.
Could you post the code with the intentional error you added?
Hi Chris -- thanks for the reply.
So, simply running the makeaddin.py from say PythonWin will not work? It seems to create a new .esriaddin file each time!
1. I am unsure if your suggestion will work for me as we are in a Citrix environment. There is no Program Files\Common Files\ArcGIS\bin\ESRIRegAddIn.exe available to us! Can that ESRIRegAddIn.exe tool be copied and run from our Citrix environment? I may have to use one of our server environments that has a full install of ArcGIS 10.1 on it in order to get this add-in built.
Unless you have a solution for us Citirx environment people?
I am kind of confused, I understood that you had a problem when double-clicking the esriaddin file. The makeaddin.py is just a python script that will zip up all the contents of the addin into a single compressed file with a .esriaddin extension. So yes, it is intended behavior that a new .esriaddin file is created each time. As far as running the makeaddin.py file, you could run it from any Python IDE or if it is already associated with an install of python you should be able to just double-click it.