Overview

You will learn: how to create and run a basic ArcGIS Pro add-in.

With ArcGIS Pro SDK for .NET, you can extend ArcGIS Pro with your own unique tools and workflows. Using Microsoft Visual Studio and the Pro SDK, you can build Pro add-ins and solution configurations that provide your users with custom functionality specific to their organization or industry. Add-ins can be developed and tailored for your specific users’ needs; for example, providing a new custom spatial analysis processing routine which leverages a custom dataset, or perhaps a new set of Pro tools which streamline a complex editing workflow.

As an introduction to developing Pro add-ins, in this lab you will use C# to create a new button which returns the current project path on the Pro UI.

Steps

Create a new ArcGIS Pro Add-In Visual Studio Project

  1. Start Visual Studio.

  2. Choose File > New > Project and then from ArcGIS templates group, select ArcGIS Pro Module Add-in.

  3. Compile and build the project.

  4. Open Windows Explorer and navigate to the folder, C:\Users\<Your user name>\Documents\ArcGIS\AddIns\ArcGISPro. You should see the add-in folder for your newly compiled add-in. Double-click the folder and you should see your add-in file within the folder, reflecting the name of your project with an .esriAddinX extension.

Create a new button using a Pro SDK template

  1. If your project is running, stop it. In the Solution Explorer, right-click the project and choose Add > New Item and then from the ArcGIS Pro Add-ins group select ArcGIS Pro Button from the list of item templates. Use the default name of Button1.cs for the new class file and press Add to close the dialog box.

  2. Type the following code into the existing OnClick method.

     string stringURI = ArcGIS.Desktop.Core.Project.Current.URI;
     ArcGIS.Desktop.Framework.Dialogs.MessageBox.Show($"Project path:  {stringURI}", "Project Info");
    
  3. Compile and build the add-in project.

Run the project

  1. Place a breakpoint in the margin of the stringURI variable declaration, and then press Start to run the add-in project in the Visual Studio debugger.

  2. At the start page, create a new empty project using the template of your choice or open an existing project.

  3. Once the project opens, click the Add-In tab. Click your new button, named Button1, which used the default name of your button class. Your breakpoint will be hit in Visual Studio which you can review in your code.

  4. Press F5 or the Continue button to continue execution. The message box should display with the project path. Press OK to close the message box.

  5. Press the Stop Debugging button in Visual Studio which will close ArcGIS Pro.

Congratulations, you're done!

Check out and compare with our completed solution project.

Challenge

Configure button UI

Try adding a caption for your button by editing Config.daml. Reference the Buttons ProGuide for more information on working with buttons in the Pro UI. Also, reference the ProConcepts Framework document for information on working with DAML.

Review the API reference

Review the Pro SDK API reference and find the Button class for more information and additional behavior.

Try other item templates

Review the ProGuide documents associated with other Pro SDK item templates found at the Pro SDK documentation site under the Framework > Customization topic. Try adding some of these to your project.