Python
Add-In Assistant provides the opportunity to extend desktop functionality by adding
and customizing tools and buttons. ArcGIS 10.1 or above have this capability.
Python
Add-In Wizard is needed and it can be downloaded here. The wizard will
generated basic codes to deploy the tools and buttons. The wizard will be
downloaded as a zip file and extraction of zip file will created folder called
‘addin_assistant’.
An
application called ‘addin_assistant.exe’ under the extracted folder will
execute the wizard. It is better to create desktop shortcut of the application
exe.
In here, a Toolbar will be added to the ArcMap. The Toolbar can be added by right clicking the TOOLBARS and clicking New Toolbar under the Add-In Contents tab. Add a caption and ID for the toolbar which will be used to python scripts.
The python script under the install folder will be edited to customize
functionality of the tool.
Start editing python script in IDLE console. Following codes are added to 'onMouseDownMap' function.
Add-in is created on the same folder with project name.
Double click the created add-in to include it to the ArcMap and then click Install Add-In. If it is successfully installed to ArcGIS folder, message will be appeared.
Usually the add-in will be copied to ArcGIS default folder (C:\Users\xxx\Documents\ArcGIS\AddIns\Desktop10.1).
Open ArcMap and the new tool will be visible.
Double click to run
‘addin_assistant.exe’ to create a project.
There
are two tabs on the open window. All the project attributes are edited under
the Project Settings tab and Tools, Button, etc are configured under the Add-In
Contents tab.
![]() |
| Python Add-In Wizard Window |
Under
the project settings,
- Set a working folder
- Set Product as ArcMap
- Add Project Properties (Name, Version, Company, Description and Author)
![]() |
| How to add a toolbar in Add-In wizard |
In here, a Toolbar will be added to the ArcMap. The Toolbar can be added by right clicking the TOOLBARS and clicking New Toolbar under the Add-In Contents tab. Add a caption and ID for the toolbar which will be used to python scripts.
![]() |
| How to add a tool to the toolbar |
To
add a tool to click on the map and retrieve coordinates, right click on the
created toolbar and add NewTool. Add a caption and ID and Message for the
created tool.
Save
the project editing and Open Folder. The folder contains project files will be opened.
![]() |
| Folder Contents of created tool |
Start editing python script in IDLE console. Following codes are added to 'onMouseDownMap' function.
def onMouseDownMap(self, x, y, button,
shift):
self.x = x
self.y = y
print 'Clicked Location Coordinates are : {:.4f} , {:.4f}'.format(x, y)
message = "Your mouse clicked on : " + str(x) + ", " + str(y)
pythonaddins.MessageBox(message, "Capture Location")
message = "Your mouse clicked on : " + str(x) + ", " + str(y)
pythonaddins.MessageBox(message, "Capture Location")
Double
click the ‘makeaddin.py’ file to create add-in.
Add-in is created on the same folder with project name.
Double click the created add-in to include it to the ArcMap and then click Install Add-In. If it is successfully installed to ArcGIS folder, message will be appeared.
Usually the add-in will be copied to ArcGIS default folder (C:\Users\xxx\Documents\ArcGIS\AddIns\Desktop10.1).
Open ArcMap and the new tool will be visible.
![]() |
| The created tool on ArcMap |








No comments:
Post a Comment