Presentation is loading. Please wait.

Presentation is loading. Please wait.

Introduction to ESRI Add-Ins

Similar presentations


Presentation on theme: "Introduction to ESRI Add-Ins"— Presentation transcript:

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

2 Agenda Introductions What are Add-ins? Python Add-ins Break
.NET Add-ins Extras

3 Set Up? Were you able to get everything installed and functional?

4 Introductions Chris Pouliot Jackie Brost
Application DNR Avenue, VB6, VB.NET, C#, Python Jackie Brost GIS DNR GIS Training & Support, Python

5 Introductions Who are you? Programming experience?
Why are you taking the class?

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) Starting with ArcGIS 10.0 Interface -- Any interface you see can be created from an Add-In Listener – Listens for application events

7 Available Add In Types .NET, Java & Python .NET or Java Only Buttons
Tools Combo Boxes Menus Toolbars Tool Palettes Application Extensions .NET or Java Only Multi-items Context Menus Dockable Windows Editor Extensions

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”

9 What are Add-ins? .esriAddIn

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

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

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 IDE = Integrated Development Environment

13 Python Add-Ins New in10.1 Pros Cons Simple Code No DLLs No ArcObjects
Uses ArcPy libraries No DLLs No ArcObjects Cons No Forms/Dialogs *Python add-ins are new in 10.1 When comparing Python add-ins to .NET and java add-ins, there are a few pros and cons. Pros – Python coding is simpler than .NET. Python uses ArcPy libraries, while .NET uses ArcObjects. not using ArcObjects will greatly simplify your code. Geoprocessing tasks written in Python are usually much shorter and more streamlined that .NET, which means less coding for you. No DLLs – security settings can make DLLs tricky to install. Not having them in your add-in will make the installation and sharing processes much easier. Cons – although it’s a ‘pro’ that you’re not using ArcObjects due to its complexity, it’s also a con because it will put limitations on the things you can do with your code. Python does not allow you to code a form or dialog box into your add-in.

14 Python Add-ins Supported Types Buttons Tools Toolbars Tool Palette
Combo boxes Menus Extensions Provides event listeners There are currently 7 supported types of Python add-ins: *Buttons *Tools *Toolbars *Tool Palettes *Extensions (which provide event listeners) *Combo Boxes *and Menus

15 Python Add-ins Not 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 Getting a little more in-depth into the ‘Cons’ we went over a couple slides back – there are a few functions you may be looking for, that are not supported through Python Add-Ins: *You won’t be able to create a dockable window with your python add-in (think of ArcCatalog and ArcToolbox – the docking functionality will be unavailable). Your Add-In will remain as a floating window until you run it or close it. *Custom forms and dialogs are not supported in Python add-ins either. There are complex ways to achieve a python-based form or dialog by running scripts within scripts using WX Python (an open source toolkit) – if you’re interested you can check out mark cedarholm’s presentation at the 2012 Esri Developer conference. *Finally, you will be limited to using the ArcPy module, and won’t have access to ArcObjects

16 Python Add-ins Steps to Create a Python Add-in
Use Python Add-In Wizard to create an Add-In framework (define buttons, tools, menus, toolbars, etc) Write Python Code behind buttons, tools, …. Compile to create a single Add-In file (makeaddin.py) Install/Distribute Add-in You’ll all get to create a python add-in for our first exercise today. Here are the 4 main steps of that process: You’ll use the python addin wizard to create an addin framework (this wizard will make the file folder structure and skeleton code, including button, tools, menu definitions, that are essential to creating your addin. After you’ve run through the addin wizard, you’ll edit the pre-generated Python code document within the add-in folder to perform your desired operations. Once you finish your python code, you’ll compile the add-in to make a single addin file (makeaddin.py) which will be conveniently placed in the addin folder with all the other components you’ve been working with. Finally, you are ready to install and share your addin.

17 Python Add-in Wizard Free download from http://www.arcgis.com
Simplifies development of Python add-in Wizard for defining project settings and add-in content The Python Addin Wizard is a free download available from esri (which you all have downloaded and installed for this class). The wizard offers a streamlined and user-friendly way to build your python addin by walking you through the steps to define project settings and addin content. Upon running through the addin wizard, you’ll have 2 folders and one xml file created for you. Config.xml folder – describes your add in and declares it’s customizations. For instance, it might declare that your add-in has a toolbar with four buttons on it, or a drop-down menu. This file is automatically created by the python addin wizard when you click the save button and includes all the info describing the addin, including the ArcGIS product, captions, tooltips, help info, images and layout details. Install Folder – holds the python script which is the active portion of the addin. For example, a button is declared in the XML configuration file, but it’s custom behavior is defined in tit’s associated Python script. This folder is also where you can add additional files & folders. It’s where you would put data, layer files, toolboxes or GDBs you want to ship as part of your add-in. Images folder – all graphics associated with the add-in will be referenced in the configuration file and copied to the images folder.

18 Python Add-in Wizard Edit Python script that’s been generated in the install folder Run makeaddin.py to create .esriaddin file Double-click .esriaddin to open installation utility Installer copies add-in to the well known default add-in folder (My Documents > ArcGIS) Once you’ve declared the types of customizations you want to create with your addin, the next thing you're going to do is author and edit the python script that’s in the install folder. The python script will define the behavior of your customizations. The pre-generated python script will contain the definition of the addin types that you specified when you went through the add-in wizard. The python script that is created for you in the install folder contains the customizations you’ve defined through the wizard. This means there will be pre-generated code for the classes you defined in the add-in wizard. If you declare a tool, you will have a class in your python script that corresponds to that tool. Each class will also define the properties and functions specific to that add-in type, making it easier to add your business logic to the appropriate location in the class. Once you’ve authored your script and defined the behavior for the add-in, you will create your add-in. To do this, you will run the makeadd-in.py script to ‘compile’ your add-in. This will create the esri addin file – the single compressed file necessary to make your addin work. Just double click the esri addin file to install. This installs the addin to your My Documents > ArcGIS folder.

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 The python addins module is new in 10.1, and supports python addins. It contains several functions that assist in common workflows added by your addin. For example, you can open a dialog and present it to a user, so they can select a file path which you can use for an input in your addin. Additionally, the module includes functions that can open a geoprcoessing tool dialog box, show a message box or return the selected layer or data frame from the table of contents.

20 Python Add-In Demo Open Add-In Wizard Create New Project Folder
Need Images for each tool. New Toolbar Unique ID – The part after decimal point is variable name referenced in Python code. New Tool (Create Map Package Tool) Class Name – Name Referenced in Python Script. Give unique name so that when you’re editing your Python script you know which class refers to which tool or customization in your addin ToolTip & Message will display when hovered over your tool, so put something informative here that will help users Help Heading & Help content will display in the customize dialog For this particular tool, we only want enabled in Data View, not Layout View. To put this functionality into our addin, we need to create a new extension that will listen for the active view change event. So when the active view changes, we want to change the event for that property to true or false. The function will run every time we change the active view. By checking the ‘load automatically’, we don’t have to have the user turn the extension on – it will already be enabled. New Extension Methods to Implement Open Config File – you can see here the xml is declaring the customizations we defined in the addin wizard. Open PY script (PythonWin?) – you can see two class definitions – one that defines the extension, and one that defines the tool. You can also see several functions that have been predefined and functions that are already set. In the tool code, you can see all the different click functions. We’re only interested in the on Rectangle event – so we can delete all the others. It’s good practice to delete any unused events. On Rectangle Delete unused functions Double click makeaddin.py

21 Python Add-In Exercise

22 Python Test/Debugging
If 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

23 .NET Add-ins What is .NET?? Development framework to build applications for the Windows Platform Key Features Common Language Runtime Base Class Library Windows Forms **If using ArcMap 10.1, .NET development using any edition of VS 2010 including Express is supported. Development using other versions of VS is not supported. **.NET framework is the minimum requirement for any .NET dev with 10.1, **.NET 4.0 can be used as long as 3.5 is also installed. Interacting with databases Parsing XML

24 .NET Add-ins What is .NET?? Interacting with databases Parsing XML
File reading and writing String manipulation Working with collections Forms and Tools **If using ArcMap 10.1, .NET development using any edition of VS 2010 including Express is supported. Development using other versions of VS is not supported. **.NET framework is the minimum requirement for any .NET dev with 10.1, **.NET 4.0 can be used as long as 3.5 is also installed.

25 .NET Add-ins What 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 **If using ArcMap 10.1, .NET development using any edition of VS 2010 including Express is supported. Development using other versions of VS is not supported. **.NET framework is the minimum requirement for any .NET dev with 10.1, **.NET 4.0 can be used as long as 3.5 is also installed.

26 .NET Add-ins Visual Studio 2008+ Express Professional Free
Doesn’t have real-time debugging (similar to Python Add-In Wizard) Professional $450 Great real-time debugging **If using ArcMap 10.1, .NET development using any edition of VS 2010 including Express is supported. Development using other versions of VS is not supported. **.NET framework is the minimum requirement for any .NET dev with 10.1, **.NET 4.0 can be used as long as 3.5 is also installed.

27 .NET Add-ins ArcGIS .NET SDK ArcObjects Libraries
Building blocks of ArcGIS products. Fine-grained control Forms, Dialogs

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) Multi-Item - A multi-item is a dynamic collection of menu items created at run time. Multi-items are useful when the items on a menu cannot be determined prior to run time or the items need to be modified based on the state of the system. Tool palettes Tool palettes provide a compact way to group a related set of tools. The most recently used tool appears on the toolbar alongside a small drop-down button used to access other tools in the group. As with menus, tools that appear on tool palettes can come from built-in sources, add-in sources, or a combination of both.

29 .NET Add-ins Examples: Quick Layers Where Window
Forest Inventory Module Hydrography Tools Private Forest Management Native Plant Communities Wildlife Surveys

30 .NET Add-ins Steps to Create a .NET Add-In in Visual Studio
Create Add-In components (button, tool, construction tool, combo box, multi-item, extension, editor extension, dockable window) Create component containers (Tool Palette, Toolbar, Menu, Context Menu) Write code behind components Compile to create a single Add-In file Install/Distribute

31 Visual Studio Demo

32 .NET Add-in Exercise

33 Add-In Versions Always increment the version.

34 Add-In Versions Anatomy of a config file.

35 Installing My Add-Ins Shared 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 Manager Installer copies add-in file to default add-in folder (C:\Users\chpoulio\Documents\ArcGIS\AddI ns\Desktop10.x\) Digitally sign add-ins Assures add-in hasn’t been modified since signing

36 Installing Customizations
Easy 10.x Effort Level 9.x 8.x Hard Time

37 Integrating Existing Components
Existing ESRI component Need the GUID of the item you’re interested in. These can be found at net/conceptualhelp/index.html#// s000000

38 Integrating Existing Components

39 Integrating Existing Components

40 Tips and Tricks Updating 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.

41 Tips and Tricks Add-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.

42 References Help Web Training Instructor-led Training
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)


Download ppt "Introduction to ESRI Add-Ins"

Similar presentations


Ads by Google