introduction to esri add-ins gis/lis conference rochester, mn october, 2014

42
Introduction to ESRI Add-Ins GIS/LIS Conference Rochester, MN October, 2014

Upload: blaze-daniels

Post on 21-Dec-2015

231 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Introduction to ESRI Add-Ins GIS/LIS Conference Rochester, MN October, 2014

Introduction to ESRI Add-InsGIS/LIS ConferenceRochester, MNOctober, 2014

Page 2: Introduction to ESRI Add-Ins GIS/LIS Conference Rochester, MN October, 2014

2

AgendaIntroductionsWhat are Add-ins?Python Add-insBreak.NET Add-insExtras

Page 3: Introduction to ESRI Add-Ins GIS/LIS Conference Rochester, MN October, 2014

3

Set Up?

Page 4: Introduction to ESRI Add-Ins GIS/LIS Conference Rochester, MN October, 2014

4

IntroductionsChris Pouliot

◦Application Developer, @MN DNR◦Avenue, VB6, VB.NET, C#, Python◦[email protected]

Jackie Brost◦GIS Specialist, @MN DNR◦GIS Training & Support, Python◦[email protected]

Page 5: Introduction to ESRI Add-Ins GIS/LIS Conference Rochester, MN October, 2014

5

Introductions

Who are you?Programming

experience?Why are you taking

the class?

Page 6: Introduction to ESRI Add-Ins GIS/LIS Conference Rochester, MN October, 2014

6

What are Add-ins?New model for ArcGIS Desktop

application customization◦Single tool or group of tools

Button, Tool, Menu, Toolbar, etc

◦Perform action in response to application event New Document, Edit, Change Extent, etc

Works on ArcGIS Desktop Products (ArcMap, ArcCatalog, ArcGlobe)

Page 7: Introduction to ESRI Add-Ins GIS/LIS Conference Rochester, MN October, 2014

7

Available Add In Types

.NET, Java & Python• Buttons• Tools• Combo Boxes• Menus• Toolbars• Tool Palettes• Application

Extensions

.NET or Java Only• Multi-items• Context Menus• Dockable Windows• Editor Extensions

Page 8: Introduction to ESRI Add-Ins GIS/LIS Conference Rochester, MN October, 2014

8

What are Add-ins?Single compressed file

(*.esriAddIn)◦Created in .NET, Java, or Python

ArcMap knows how to install and use◦VERY easy to distribute and manage◦“Well Known Folders”

Page 9: Introduction to ESRI Add-Ins GIS/LIS Conference Rochester, MN October, 2014

9

What are Add-ins?

.esriAddIn

Page 10: Introduction to ESRI Add-Ins GIS/LIS Conference Rochester, MN October, 2014

10

When to Use an Add-in?If only rearranging existing tools

into custom toolbar do this in MXD or MXT with no code.

If running a process or batch job of geoprocessing tools then create a model or create a tool in toolbox using python

Page 11: Introduction to ESRI Add-Ins GIS/LIS Conference Rochester, MN October, 2014

11

When to Use an Add-in?If you need to interact with the

User Interface – Map, Layout, Table of Contents, etc then use an addin

If you need code to run based on an ArcMap event (layer turned on/off, new document opened, changed data frame, feature edited) then use an addin

Page 12: Introduction to ESRI Add-Ins GIS/LIS Conference Rochester, MN October, 2014

12

What Languages and IDEs?.NET (C#, VB.NET)

◦Visual Studio 2008+ Visual Studio 2012 works with ArcGIS10.2 Visual Studio 2010 works with ArcGIS 10.1

◦ .NET SDK (Comes with ArcGIS Install) Installed AFTER Visual Studio

Java◦Eclipse◦ .NET SDK (Comes with ArcGIS Install)

Python (New with ArcGIS 10.1!!)◦PyWIN, PyScripter, etc◦Python Add-In Assistant

Page 13: Introduction to ESRI Add-Ins GIS/LIS Conference Rochester, MN October, 2014

13

Python Add-InsNew in10.1Pros

◦Simple Code Uses ArcPy libraries

◦No DLLs◦No ArcObjects

Cons◦No ArcObjects◦No Forms/Dialogs

Page 14: Introduction to ESRI Add-Ins GIS/LIS Conference Rochester, MN October, 2014

14

Python Add-insSupported Types

◦Buttons ◦Tools◦Toolbars◦Tool Palette◦Combo boxes◦Menus◦Extensions

Provides event listeners

Page 15: Introduction to ESRI Add-Ins GIS/LIS Conference Rochester, MN October, 2014

15

Python Add-insNot Supported

◦Dockable Windows◦UI (Custom Forms and Dialogs)

Mark Cedarholm – presentation at ESRI’s 2012 Developers Conference was able to create custom forms using WX Python.

◦ArcObjects – limited to arcpy python module

Page 16: Introduction to ESRI Add-Ins GIS/LIS Conference Rochester, MN October, 2014

16

Python Add-ins

Steps to Create a Python Add-in1. Use Python Add-In Wizard to create

an Add-In framework (define buttons, tools, menus, toolbars, etc)

2. Write Python Code behind buttons, tools, ….

3. Compile to create a single Add-In file (makeaddin.py)

4. Install/Distribute Add-in

Page 17: Introduction to ESRI Add-Ins GIS/LIS Conference Rochester, MN October, 2014

17

Python Add-in WizardFree download from http://www.arcgis.comSimplifies development of Python add-inWizard for defining project settings and add-in

content

Page 18: Introduction to ESRI Add-Ins GIS/LIS Conference Rochester, MN October, 2014

18

Python Add-in WizardEdit Python script that’s been

generated in the install folderRun makeaddin.py to

create .esriaddin fileDouble-click .esriaddin to open

installation utilityInstaller copies add-in to the well

known default add-in folder (My Documents > ArcGIS)

Page 19: Introduction to ESRI Add-Ins GIS/LIS Conference Rochester, MN October, 2014

19

Python Add-ins Module

New module in Python that enhances Includes functions for supporting Python add-ins◦Get selected layer or data frame◦Open gp tool◦Open and save dialog boxes◦Message box

Page 20: Introduction to ESRI Add-Ins GIS/LIS Conference Rochester, MN October, 2014

20

Python Add-In Demo

Page 21: Introduction to ESRI Add-Ins GIS/LIS Conference Rochester, MN October, 2014

21

Python Add-In Exercise

Page 22: Introduction to ESRI Add-Ins GIS/LIS Conference Rochester, MN October, 2014

22

Python Test/DebuggingIf tool shows <missing> means

probably a syntax error in the config.xml file. Use IDE to check this.

Use Print statements◦Information printed to Python

window Assures proper values in variables

◦Exceptions printed to Python window

Page 23: Introduction to ESRI Add-Ins GIS/LIS Conference Rochester, MN October, 2014

23

.NET Add-insWhat is .NET??

◦Development framework to build applications for the Windows Platform

◦Key Features Common Language Runtime Base Class Library Windows Forms

Page 24: Introduction to ESRI Add-Ins GIS/LIS Conference Rochester, MN October, 2014

24

.NET Add-insWhat is .NET??

◦Interacting with databases◦Parsing XML◦File reading and writing◦String manipulation◦Working with collections◦Forms and Tools

Page 25: Introduction to ESRI Add-Ins GIS/LIS Conference Rochester, MN October, 2014

25

.NET Add-insWhat version of .NET should I be

using?◦.NET 4.0 is supported at 10.1 and 10.2◦.NET 3.5 is installed with ArcMap

Page 26: Introduction to ESRI Add-Ins GIS/LIS Conference Rochester, MN October, 2014

26

.NET Add-insVisual Studio 2008+

◦Express Free http://www.microsoft.com/visualstudio/

eng/downloads Doesn’t have real-time debugging (similar

to Python Add-In Wizard)

◦Professional $450 Great real-time debugging

Page 27: Introduction to ESRI Add-Ins GIS/LIS Conference Rochester, MN October, 2014

27

.NET Add-insArcGIS .NET SDKArcObjects Libraries

◦Building blocks of ArcGIS products.◦Fine-grained control◦Forms, Dialogs

Page 28: Introduction to ESRI Add-Ins GIS/LIS Conference Rochester, MN October, 2014

28

.NET Add-ins Supported Types

◦ Buttons◦ Tools◦ Combo boxes◦ Multi-Items◦ Menus◦ Context Menus◦ Toolbars◦ Tool Palettes◦ Dockable Windows◦ Application Extensions◦ Editor Extensions◦ Editor Construction Tools◦ SOE (Server)

Page 29: Introduction to ESRI Add-Ins GIS/LIS Conference Rochester, MN October, 2014

29

.NET Add-insExamples:

◦Quick Layers◦Where Window◦Forest Inventory Module◦Hydrography Tools◦Private Forest Management◦Native Plant Communities◦Wildlife Surveys

Page 30: Introduction to ESRI Add-Ins GIS/LIS Conference Rochester, MN October, 2014

30

.NET Add-insSteps to Create a .NET Add-In in

Visual Studio1. Create Add-In components (button,

tool, construction tool, combo box, multi-item, extension, editor extension, dockable window)

2. Create component containers (Tool Palette, Toolbar, Menu, Context Menu)

3. Write code behind components4. Compile to create a single Add-In file5. Install/Distribute

Page 31: Introduction to ESRI Add-Ins GIS/LIS Conference Rochester, MN October, 2014

31

Visual Studio Demo

Page 32: Introduction to ESRI Add-Ins GIS/LIS Conference Rochester, MN October, 2014

32

.NET Add-in Exercise

Page 33: Introduction to ESRI Add-Ins GIS/LIS Conference Rochester, MN October, 2014

33

Add-In VersionsAlways increment the version.

Page 34: Introduction to ESRI Add-Ins GIS/LIS Conference Rochester, MN October, 2014

34

Add-In VersionsAnatomy of a config file.

Page 35: Introduction to ESRI Add-Ins GIS/LIS Conference Rochester, MN October, 2014

35

InstallingMy Add-Ins

◦Double-Click the .esriaddin file to open installation utility

Shared Add-Ins◦Copy .esriaddin file to a Well Known Folder

specified in ArcMap’s Add-In ManagerInstaller copies add-in file to default add-

in folder (C:\Users\chpoulio\Documents\ArcGIS\AddIns\Desktop10.x\)

Digitally sign add-ins◦Assures add-in hasn’t been modified since

signing

Page 36: Introduction to ESRI Add-Ins GIS/LIS Conference Rochester, MN October, 2014

36

Installing CustomizationsEasy

Hard

Time

8.x

Eff

ort

Level

9.x

10.x

Page 37: Introduction to ESRI Add-Ins GIS/LIS Conference Rochester, MN October, 2014

37

Integrating Existing ComponentsExisting ESRI component

◦Need the GUID of the item you’re interested in. These can be found at http://help.arcgis.com/en/sdk/10.0/arcobjects_net/conceptualhelp/index.html#//00010000029s000000

Page 38: Introduction to ESRI Add-Ins GIS/LIS Conference Rochester, MN October, 2014

38

Integrating Existing Components

Page 39: Introduction to ESRI Add-Ins GIS/LIS Conference Rochester, MN October, 2014

39

Integrating Existing Components

Page 40: Introduction to ESRI Add-Ins GIS/LIS Conference Rochester, MN October, 2014

40

Tips and TricksUpdating Add-In

◦If placing in an Add-In folder do NOT leave old version there. Arcmap will see it even if you rename it and change the file extension.

Page 41: Introduction to ESRI Add-Ins GIS/LIS Conference Rochester, MN October, 2014

41

Tips and TricksAdd-In folder locations

◦Arcmap is slow in navigating file systems, especially across a VPN. If you do put your add-ins in a location on a network, put them in a single folder without any other extraneous files.

Page 42: Introduction to ESRI Add-Ins GIS/LIS Conference Rochester, MN October, 2014

42

ReferencesHelp

◦ArcGIS Desktop Python Add-ins Guide Book

Web Training◦Basics of Python (for ArcGIS 10)◦Python Scripting for Map Automation in

ArcGIS 10◦Creating Desktop Add-ins Using Python

Instructor-led Training◦Introduction to Geoprocessing Scripts

Using Python (10.0)