Introduction to ArcGIS Add-Ins Exercises GIS/LIS Conference, 2014 Rochester, MN.

Slides:



Advertisements
Similar presentations
Office 2003 Post-Advanced Concepts and Techniques M i c r o s o f t Excel Project 7 Using Macros and Visual Basic for Applications (VBA) with Excel.
Advertisements

Using Macros and Visual Basic for Applications (VBA) with Excel
Excel Understanding Excel Fundamentals Microsoft Office 2010 Fundamentals 1.
Microsoft Office 2010 Access Chapter 1 Creating and Using a Database.
© by Pearson Education, Inc. All Rights Reserved.
Visual Basic 2010 How to Program. © by Pearson Education, Inc. All Rights Reserved.2.
Visual Basic 2010 How to Program Reference: Instructor: Maysoon Bin Duwais slides Visual Basic 2010 how to program by Deitel © by Pearson Education,
Microsoft Excel 2010 Chapter 7
Chapter 1 Databases and Database Objects: An Introduction
Integrating Access with the Web and with Other Programs.
Technical Support: (989) GIS and Mapping Procedures in ArcMap 9.x Creating an ArcMap Project Editing an ArcMap Project Printing an ArcMap Project.
Intro to ArcMap Customization with Visual Basic  Create your own toolbars, buttons, interactive tools, and programs  Runs behind the scenes in ArcMap.
Copyright 2007, Paradigm Publishing Inc. POWERPOINT 2007 CHAPTER 1 BACKNEXTEND 1-1 LINKS TO OBJECTIVES Create Presentation Open, Save, Run, Print, Close,Delete.
1 of 6 This document is for informational purposes only. MICROSOFT MAKES NO WARRANTIES, EXPRESS OR IMPLIED, IN THIS DOCUMENT. © 2007 Microsoft Corporation.
Macros Tutorial Week 20. Objectives By the end of this tutorial you should understand how to: Create macros Assign macros to events Associate macros with.
1 of 5 This document is for informational purposes only. MICROSOFT MAKES NO WARRANTIES, EXPRESS OR IMPLIED, IN THIS DOCUMENT. © 2007 Microsoft Corporation.
Introduction to ESRI Add-Ins
Office 2003 Post-Advanced Concepts and Techniques M i c r o s o f t Word Project 8 Working with Macros and Visual Basic for Applications (VBA)
Working with SharePoint Document Libraries. What are document libraries? Document libraries are collections of files that you can share with team members.
Lesley Bross, August 25, 2010 ArcGIS 10 Add-In Components and Controls.
Access Tutorial 10 Automating Tasks with Macros
Chapter 2 Querying a Database
Microsoft Visual Basic 2005 ENRICHMENT CHAPTER Visual Studio Tools for Office.
Microsoft Visual Basic 2005 CHAPTER 8 Using Procedures and Exception Handling.
Microsoft Visual Basic 2012 CHAPTER TWELVE (ENRICHMENT CHAPTER) Windows Store Apps.
Microsoft ® Word Templates and Accessibility. 1 What is a Word template? File with a.dot (document template) extension Can define the following:  Paragraph.
Chapter 2 Querying a Database MICROSOFT ACCESS 2010.
Microsoft Visual Basic 2012 Using Procedures and Exception Handling CHAPTER SEVEN.
EDU 271. Introduction to Microsoft Publisher  Microsoft Publisher helps you easily create, customize, and publish materials such as: newsletters, brochures,
Chapter 1 Databases and Database Objects: An Introduction
Microsoft Official Academic Course, Microsoft Word 2013
| | Tel: | | Computer Training & Personal Development Outlook Express Complete.
XP New Perspectives on Microsoft Office FrontPage 2003 Tutorial 4 1 Microsoft Office FrontPage 2003 Tutorial 4 – Using Shared Borders and Themes.
T U T O R I A L  2009 Pearson Education, Inc. All rights reserved. 1 2 Welcome Application Introducing the Visual Basic 2008 Express Edition IDE.
Office 2003 Advanced Concepts and Techniques M i c r o s o f t Access Web Feature Data Access Pages.
Chapter 6 Generating Form Letters, Mailing Labels, and a Directory
A First Look At Microsoft Visual Basic Lesson 1. What is Microsoft Visual Basic? Microsoft Visual Basic is a software development tool, which means it.
Microsoft Office Word 2013 Expert Microsoft Office Word 2013 Expert Courseware # 3251 Lesson 3: Customizing Document Elements.
Office of Education Technology (OET) Active Directory Bulk Import Saturday March 11, 2006 /8:30 – 10:30 AM.
Alice 2.0 Introductory Concepts and Techniques Project 1 Exploring Alice and Object-Oriented Programming.
Teacher’s Assessment Assistant Worksheet Builder Starting the Program
Microsoft Visual Basic 2005 ENRICHMENT CHAPTER Visual Studio Tools for Office.
Microsoft Publisher 2010 Chapter 7 Advanced Formatting and Merging Publications with Data.
Microsoft Access 2010 Chapter 10 Administering a Database System.
Using Microsoft Visual Studio C++ Express 2005 Name: Dr Ju Wang Ashwin Belle Course Resource:
Visual Basic.NET BASICS Lesson 1 A First Look at Microsoft Visual Basic.NET.
Visual Basic.NET Comprehensive Concepts and Techniques Chapter 8 Debugging, Creating Executable Files, and Distributing a Windows Application.
XP New Perspectives on Microsoft Office FrontPage 2003 Tutorial 7 1 Microsoft Office FrontPage 2003 Tutorial 7 – Creating and Using Templates in a Web.
Microsoft Visual Basic 2005 BASICS Lesson 1 A First Look at Microsoft Visual Basic.
Office 2003 Advanced Concepts and Techniques M i c r o s o f t Access Project 6 Creating an Application System Using Macros, Wizards, and the Switchboard.
Lab 0 / Chapter 0 Windows XP Environment. 2 User Interfaces: A different perspective.
XP New Perspectives on Microsoft Office FrontPage 2003 Tutorial 7 1 Microsoft Office FrontPage 2003 Tutorial 8 – Integrating a Database with a FrontPage.
Editing Basics Lesson 8. Skills Matrix SKILL #MATRIX SKILL 2.2.1Cut, copy, and paste text 2.2.2Find and replace text 4.1.1Insert building blocks in documents.
INTRODUCTION TO ACCESS. OBJECTIVES  Define the terms field, record, table, relational database, primary key, and foreign key  Create a blank database.
Modify Tables and FieldsModify Tables and Fields Lesson 4 © 2014, John Wiley & Sons, Inc.Microsoft Official Academic Course, Microsoft Word Microsoft.
XP New Perspectives on Microsoft Office Access 2003, Second Edition- Tutorial 8 1 Microsoft Office Access 2003 Tutorial 8 – Integrating Access with the.
Intoduction to Andriod studio Environment With a hello world program.
Create FormsCreate Forms Lesson 5 © 2014, John Wiley & Sons, Inc.Microsoft Official Academic Course, Microsoft Access Microsoft Access 2013.
Chapter 7 Creating Templates, Importing Data, and Working with SmartArt, Images, and Screen Shots Microsoft Excel 2013.
Working with Tables A table is a grid of cells arranged in rows and columns. Tables can be customized and are useful for various tasks such as presenting.
Chapter 11 Enhancing an Online Form and Using Macros Microsoft Word 2013.
Dive Into® Visual Basic 2010 Express
DRAWING LINES To draw lines click View in the Main Menu Toolbar -> Toolbars and check the Editor option. The Editor toolbar will appear amongst the toobars.
Chapter 2 – Introduction to the Visual Studio .NET IDE
Word Tutorial 6 Using Mail Merge
Introduction to ArcGIS Add-Ins
1. Open Visual Studio 2008.
Microsoft Office Access 2003
Microsoft Office Access 2003
Chapter 1 Databases and Database Objects: An Introduction
Presentation transcript:

Introduction to ArcGIS Add-Ins Exercises GIS/LIS Conference, 2014 Rochester, MN

Exercise 1 – Add-Ins with Python In this exercise you will be using the Python Add-In Wizard and PyScripter to create an Add-In to ArcMap that contains a toolbar with a tool for creating a map package file (.mpk). 1.Open the Python Add-In Wizard by Double-clicking on the AddIn Assistant shortcut on your desktop. 2.The first thing you’ll need to do is define your Add-In project root folder. Navigate to C:\temp\IntroductiontoAddInsforArcGIS\Exercise1 and create a folder called ‘CreateMapPackage’ Click ‘OK’ 2Introduction to ArcGIS Add-ins

3.In the Wizard window that appears enter the information as shown in the graphic to the right. Select Product: ArcMap Name: Create Map Package Tool Version: 1.0 Company: MN DNR Description: Provides a tool to create a map package based on the user defined extent. Author: Image: C:\temp\Introduction to AddIns for ArcGIS\Exercise1\ Package64.png. 4.Click on the ‘Add-In Contents’ Tab 3Introduction to ArcGIS Add-ins

5.In the contents tab you can define buttons/tools/etc to be included in the add-in. Add a toolbar by right-clicking on the TOOLBARS item and select ‘New Toolbar’. Enter the information as shown in the graphic below. Caption: Map Package ID: CreateMapPackage_addin.mpktoolbar Show Initially: Checked 4Introduction to ArcGIS Add-ins

6.Under your new Map Package toolbar add a new Tool by right-clicking on the ‘Map Package’ item and select ‘New Tool’. Enter the information as shown in the graphic below. Caption: Create Map Package Class Name: CreateMPKTool ID: CreateMapPackage_addin.mpktool Tooltip: Create Map Package Message: Create Map Package for user defined extent Help Heading: Create Map Package Help Content: Create Map Package for user defined extent Image: C:\temp\Introduction to AddIns for ArcGIS\Exercise1\ Package16.png 5Introduction to ArcGIS Add-ins

7.Next add an extension that will listen for changes to the Active View. Add an extension by right-clicking on the ‘EXTENSIONS’ item and select ‘New Extension’. Enter the information as shown in the graphic below. Name: Create Map Package Class Name: CreateMPKExt ID: CreateMapPackage_addin.mpkext Description: Checks Active View and disables Create Map Package if the Active View is Page Layout Methods to Implement: ActiveViewChanged Click ‘Save’. The Add-In structure is created in the C:\temp\IntroductiontoAddIns forArcGIS\Exercise1\ CreateMapPackage folder 6Introduction to ArcGIS Add-ins

8.The Add-In structure has been created in the C:\temp\IntroductiontoAddInsfor ArcGIS\Exercise1\CreateMapPackage folder. The next step is to modify the code behind the tool and extension so that they perform as expected. Open Windows Explorer and navigate to C:\temp\IntroductiontoAddInsforArcGIS\Exercise1\CreateMapPackage\Install. Right-click on the CreateMapPackage_addin.py file and select ‘Edit With PyScripter’. 7Introduction to ArcGIS Add-ins

9.Some custom code needs to be added to this file. For simplicity, the code is sitting in a text file at C:\temp\IntroductiontoAddInsforArcGIS\Exercise1\customCode.txt. Open this file and copy its contents. Replace ALL of the code in the CreateMapPackage_addin.py and then Save your Changes (File  Save). It should look similar to the screen shot below: 8Introduction to ArcGIS Add-ins

10.All the pieces are now ready to be compiled into the ESRI Add-In. Go to C:\temp\IntroductiontoAddInsforArcGIS\Exercise1\CreateMapPackage and double-click on the makeaddin.py file. This will create the add-in file in the same directory. 11.Install the Add-in. To do this, double-click on the file (C:\temp\IntroductiontoAddInsforArcGIS\Exercise1\CreateMapPackage\CreateMapPackage.esriaddin). When the Installation Utility appears click on ‘Install Add-In’. 9Introduction to ArcGIS Add-ins

12.Now test the add-in. Launch ArcMap and open the sample project at C:\temp\IntroductiontoAddInsforArcGIS\Exercise1\sampleMap.mxd. 13.Turn on the Create Map Package Extension by going to Customize  Extensions and checking “on” the Create Map Package extension. Your new toolbar should be visible with your one tool. If it’s not, go to Customize  Toolbars and turn on the Create Map Package toolbar. To use the tool select it and then click and drag a rectangle on the map. All data within that rectangle will be extracted and bundled and saved out to a map package located next to the sampleMap.mxd called sampleMap.mpk. 10Introduction to ArcGIS Add-ins

Exercise 2 – Add-Ins with Visual Studio In this exercise you will be using Visual Studio Express 2010 to create an Add-In to ArcMap that contains a toolbar with two tools – one for finding upstream watersheds and one for finding downstream watersheds from a user’s mouse-click. 1.Open Visual Studio by Double-clicking on the Visual Studio shortcut on your desktop or from the Start menu. 2.Select “New Project” from the options on the left side of the window that opens. 3.Select “Desktop Add-Ins” on the left side, “ArcMap Add-in” from the middle pane, and at the bottom of the New Project window type in “WatershedTools” for the name of your Add-in project. Click ‘OK’. 11Introduction to ArcGIS Add-ins

4.Enter the information as shown in the graphic to the right. Add-in Name: WatershedTools Company: MN DNR Author: Description: These tools are for analyzing watersheds. Image: C:\temp\Introduction toAddInsforArcGIS\Exercise2\ Watershed.png. Click ‘Next’ 12Introduction to ArcGIS Add-ins

5.Enter the information as shown in the graphic to the right. Add-in Type: Tool Class Name: toolUpstream Caption: Find Upstream Watersheds Image: C:\temp\Introduction to AddIns for ArcGIS\Exercise2\Upstream.png Category: Watershed On Demand: Checked Tooltip: Find Upstream Watersheds Description: This tool selects all watersheds upstream of a user’s click Click ‘Finish’ A new project is created with the parameters that you’ve chosen – an Add-in with an upstream tool. The next step is to add the downstream tool. 13Introduction to ArcGIS Add-ins

6.Next you’ll add the 2 nd tool to your project. To do this go to Project  Add New Item. Select the options as shown below: Installed Template: Desktop Add-ins Type: Add-in Component Name: toolDownstream.vb Click ‘Add’ 14Introduction to ArcGIS Add-ins

7.Enter the information as shown in the graphic to the right. Add-in Type: Tool Class Name: toolDownstream Caption: Find Downstream Watersheds Image: C:\temp\IntroductiontoAddIns forArcGIS\Exercise2\Downstream.png Category: Watershed On Demand: Checked Tooltip: Find Downstream Watersheds Description: This tool selects all watersheds downstream of a user’s click Click ‘Finish’ The new tool is added to your project. 15Introduction to ArcGIS Add-ins

8.Next you’ll add the toolbar which will contain the two tools. To do this go to Project  Add New Item. Enter the information as shown in the graphic below. Installed Template: Desktop Add-ins Type: Add-in Command Container Name: toolbarWatershedTools.vb Click ‘Add’ 16Introduction to ArcGIS Add-ins

9.Enter the information as shown in the graphic below. Add-in Command Bar Type: Toolbar Caption: Watershed Tools Premier Toolbar: Unchecked Items: Select the Upstream and Downstream tools from the combobox Click ‘Finish’ 17Introduction to ArcGIS Add-ins

10.There is some preexisting code that needs to be added which does the actual work behind the tools. To add it to the project go to Project  Add Existing Item. Add this file: C:\temp\IntroductiontoAddInsforArcGIS\Exercise2\ArcMapCode.vb. 11.This custom code also requires that some ArcObjects references be loaded. Go to Project  Add Reference and add the following.NET References (Note: You can click on the Component Name column header to sort the list): ESRI.ArcGIS.Carto ESRI.ArcGIS.Display ESRI.ArcGIS.Editor ESRI.ArcGIS.Geodatabase ESRI.ArcGIS.Geometry ESRI.ArcGIS.Location 18Introduction to ArcGIS Add-ins

12.You now have all the pieces necessary for your Add-In toolbar. Now add functionality to the tools. Open the toolDownstream.vb file and update it to look like the graphic below: Protected Overrides Sub OnMouseDown(ByVal arg As ESRI.ArcGIS.Desktop.AddIns.Tool.MouseEventArgs) MyBase.OnMouseDown(arg) ArcMapCode.HU_Find_Downstream(arg.X, arg.Y) End Sub 19Introduction to ArcGIS Add-ins

13.Do the same for the Upstream tool. Open the toolUpstream.vb file and update it to look like the graphic below: Protected Overrides Sub OnMouseDown(ByVal arg As ESRI.ArcGIS.Desktop.AddIns.Tool.MouseEventArgs) MyBase.OnMouseDown(arg) ArcMapCode.HU_Find_Upstream(arg.X, arg.Y) End Sub 20Introduction to ArcGIS Add-ins

14.Next save your project. Go to File  Save All. All files and images will be saved to the same project directory. 15.Now compile by going to Debug  Build Watershed Tools. (If using Visual Studio 2012, go to Build  Build Watershed Tools.) This will build the Add-In at C:\temp\IntroductiontoAddInsforArcGIS\Exercise2\WatershedTools\ WatershedTools\bin\Release\WatershedTools.esriAddIn and it also installs it to Arcmap’s well-known Add- In folder located at c:\Users\ \Documents\ArcGIS\AddIns\Desktop Introduction to ArcGIS Add-ins

16.To test your add-in, open the test MXD located at C:\temp\IntroductiontoAddInsforArcGIS\Exercise2\Watersheds.mxd. Go to Customize  Toolbars  Watershed Tools to open your toolbar. Select the Watershed layer by single clicking on it in the table of contents. Select the Upstream or Downstream tool and click on a watershed. The respective upstream/downstream path for that watershed should become selected. 22Introduction to ArcGIS Add-ins