This tutorial demonstrates how to create and run a basic ArcGIS Pro add-in.
With the 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, developers can build Pro add-ins and solution configurations that provide users with custom functionality specific to their organization or industry. Add-ins can be developed and tailored to your specific users’ needs; for example, providing a new custom spatial analysis processing routine which leverages a custom dataset, or create a new set of Pro tools that streamline a complex editing workflow.
This tutorial is an introduction to developing ArcGIS Pro add-ins. You will use C# to create a new button which returns the current project path on the ArcGIS Pro UI.
Prerequisites
- Microsoft Visual Studio is required. See the ArcGIS Pro system requirements for latest version and compatibility.
- Install ArcGIS Pro version 3.3 or higher.
- Install the ArcGIS Pro SDK for .NET. See the Installation ProGuide for more information.
Steps
Create a new ArcGIS Pro Add-In Visual Studio Project
-
Start Visual Studio.
-
Choose File > New > Project and then from ArcGIS templates group, select ArcGIS Pro Module Add-in.
By default, the
Config.daml
file opens in Visual Studio. TheModule1.cs
file contains add-in module code.Note also in the
Config.daml
file that theid
attribute of theinsert
tag matches the ID within theModule Module1.cs
file and that theclass
attribute matches the class name of the module.Name To find the ArcGIS templates group, see Templates > Visual C# > ArcGIS. Also confirm that the latest .NET Framework is selected.
-
Compile and build the project.
If you have errors in your output window, confirm that you have correctly installed ArcGIS Pro and the ArcGIS Pro SDK for .NET. As long as you have not changed the syntax in any of the generated files (from the Project template), there should be no compilation errors.
-
From Windows Explorer, navigate to 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 to find your add-in file within the folder, reflecting the name of your project with an
.esri
extension. The name of the folder corresponds to the ID (GUID) of your add-in as found in yourAddin X Config.daml
file.
Create a new button using a Pro SDK template
-
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.The
Button1.cs
file should open by default. If not, open the file. See the ArcGIS Pro wiki for more information on the Pro Button template. -
Type the following code into the existing
On
method.Click The
On
method was automatically generated by the template.Click The first line creates a string variable which contains the project’s URI path; the second line shows a simple dialog box containing the value of the string variable with the path and a caption.
Use dark colors for code blocks Copy string stringURI = ArcGIS.Desktop.Core.Project.Current.URI; ArcGIS.Desktop.Framework.Dialogs.MessageBox.Show($"Project path: {stringURI}", "Project Info");
-
Compile and build the add-in project.
Run the project
-
Place a breakpoint in the margin of the
string
variable declaration, and then press Start to run the add-in project in the Visual Studio debugger. ArcGIS Pro will start and show the start page.URI -
From the start page, create a new empty project using a template of your choice or open an existing project. If creating a new project, specify a name and location of your choice.
-
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.
-
Press F5 or Continue to continue execution. The message box should display with the project path. Press OK to close the message box.
-
Press Stop Debugging in Visual Studio, which will close ArcGIS Pro.
What's next?
Learn how to use additional ArcGIS Pro SDK for .NET features in these tutorials: