Arcpy
In this practical, we'll convert the code we have so far so it runs as an addin. Make yourself a new directory m:\GEOG5790M\practical3\addin in readiness.
First, work your way through the ESRI addin tutorials, using their code to build a "Hello World" button addin:
- What is an addin? (basic intro: download the wizard – you can unzip it to any directory; which is what they mean by "install")
- Essential concepts (key things to be aware of going forward)
- Creating an addin project (make your first addin project)
Using the following inputs for your project:
Working Folder: m:\GEOG5790M\practical3\addin
Select Product: ArcMap
Name: Explosion Addin
(Other elements as you feel) - Creating an addin toolbar (make a toolbar for our addin)
Using the following inputs for your toolbar:
Caption: Model Toolbar
ID: addin_addin.modeltoolbar
Show Initially: Tick (this makes it a "premier" toolbar, which is automatically shown on startup. If it disappears you can show it under Customize menu -> Toolbars) - Creating an addin button (make an addin)
Using the following inputs for your button:
Caption: Explosion Assessment
Class Name: ExplosionButtonClass
ID: addin_addin.explosionbutton
(Other elements as you feel)
And the following code foronClick()
:
pythonaddins.MessageBox("Hello world", "Hello")
- Testing an addin (add the addin to Arc)
Double clicking their build file should work in our lab, but if not it needs running with Python 2 (see last practical for how to do this).
Also, for information useful later, check out:
Starting with this button, we'll now adapt the code to run our model from the last practical.
- This page
- Making our script an addin <-- next