-
Notifications
You must be signed in to change notification settings - Fork 119
ProGuide Build your first add in
This guide demonstrates how to build an ArcGIS Pro add-in.
Language: C#
Subject: Framework
Contributor: ArcGIS Pro SDK Team <[email protected]>
Organization: Esri, http://www.esri.com
Date: 10/06/2024
ArcGIS Pro: 3.4
Visual Studio: 2022
Prerequisite: Before you can build your first add-in, you have to install ArcGIS Pro and the corresponding version of the ArcGIS Pro SDK on your development machine. For details on how to install the ArcGIS Pro SDK you can follow the installation instructions in this ProGuide: Install ArcGIS Pro SDK for .NET.
Step 1
Open Visual Studio and select New Project.
Step 2
On the New Project dialog box, expand the Templates\Visual C#\ArcGIS or Templates\Visual Basic\ArcGIS folder. Select the ArcGIS Pro Add-ins folder (you may have other folders there if you also have the ArcObjects 10.x SDK for .NET installed).
Step 3
The ArcGIS Pro Module Add-in Visual Studio project item template displays. Select it and type ProAppModule1 for the name. Change the location or accept the default. Click OK.
Step 4
Visual Studio creates a new Visual C# or Visual Basic project for you. For the purposes of this document, Visual C# will be assumed; however, the procedure is almost identical for Visual Basic. You will notice the following content in your new project:
The Config.daml file opens (by default) in Visual Studio. The Module1.cs file contains your add-in module code. The code will be similar to this:
internal class Module1 : Module {
private static Module1 _this = null;
/// <summary>
/// Retrieve the singleton instance to this module here
/// </summary>
public static Module1 Current => _this ?? =
(Module1)FrameworkApplication.FindModule("ProAppModule1_Module");
}
Note that the module contains a private reference to your module instance, which is a singleton. The string "ProAppModule1_Module" is your module ID. Framework uses this ID to reference your module in the DAML file and to find your associated module instance in the FindModule method of the FrameworkApplication module. By default, your module class is called Module1. The default namespace is the name you entered on the New Project dialog box, which in this case, is ProAppModule1.
Note also in the Config.daml file that the id attribute of the insertModule tag matches the ID within the Module1.cs file and the className attribute also matches the class name of the module.
<modules>
<insertModule id="ProAppModule1_Module" className="Module1" autoLoad="false" caption="Module1">
Step 5
Compile and build the project. If you have errors in your output window, check that you have the ArcGIS Pro application and the ArcGIS Pro SDK for .NET correctly installed. 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.
Step 6
Open Windows Explorer. Navigate to the C:\Users\<Your user name>\Documents\ArcGIS\AddIns\ArcGISPro
folder. You should see the add-in folder for your newly compiled add-in. The name of the folder corresponds to the ID (GUID) of your add-in.
<AddInInfo id="{8e95b131-d203-4775-9617-07481fbdfa32}" ...
Double-click the folder. You will see your add-in file within the folder.
Step 7 Right-click the project title within Visual Studio and select Add > New Item from the Project Context menu.
From the Visual Studio Add New Item dialog box, choose ArcGIS Pro Button from the list of available ArcGIS Pro SDK Item templates. Keep the default name Button1.cs and click OK.
Step 8
Within Visual Studio you should now see a new file, Button1.cs, that has been added to your project. Double-click that file and type the following code into the OnClick method:
internal class Button1 : Button {
protected override void OnClick()
{
string uri = ArcGIS.Desktop.Core.Project.Current.URI;
ArcGIS.Desktop.Framework.Dialogs.MessageBox.Show($"Project uri {uri}");
}
}
Step 9
Build and compile your add-in.
Step 10
Place a breakpoint in the margin of your OnClick method and run your add-in in the Visual Studio debugger.
Step 11
ArcGIS Pro starts. Allow ArcGIS Pro to complete its initialization. Create a new empty project using the template of your choice or open one of your existing projects.
Step 12
Click Add-In tab and click the Button 1 add-in button.
Step 13
Your breakpoint will be hit in Visual Studio. Press F5 or click the Continue button to continue execution. The following message box displays.
Click OK. Stop debugging.
Home | API Reference | Requirements | Download | Samples
- Overview of the ArcGIS Pro SDK
- What's New for Developers at 3.4
- Installing ArcGIS Pro SDK for .NET
- Release notes
- Resources
- Pro SDK Videos
- ProSnippets
- ArcGIS Pro API
- ProGuide: ArcGIS Pro Extensions NuGet
Migration
- ProSnippets: Framework
- ProSnippets: DAML
- ProConcepts: Framework
- ProConcepts: Asynchronous Programming in ArcGIS Pro
- ProConcepts: Advanced topics
- ProGuide: Custom settings
- ProGuide: Command line switches for ArcGISPro.exe
- ProGuide: Reusing ArcGIS Pro Commands
- ProGuide: Licensing
- ProGuide: Digital signatures
- ProGuide: Command Search
- ProGuide: Keyboard shortcuts
Add-ins
- ProGuide: Installation and Upgrade
- ProGuide: Your first add-in
- ProGuide: ArcGIS AllSource Project Template
- ProConcepts: Localization
- ProGuide: Content and Image Resources
- ProGuide: Embedding Toolboxes
- ProGuide: Diagnosing ArcGIS Pro Add-ins
- ProGuide: Regression Testing
Configurations
Customization
- ProGuide: The Ribbon, Tabs and Groups
- ProGuide: Buttons
- ProGuide: Label Controls
- ProGuide: Checkboxes
- ProGuide: Edit Boxes
- ProGuide: Combo Boxes
- ProGuide: Context Menus
- ProGuide: Palettes and Split Buttons
- ProGuide: Galleries
- ProGuide: Dockpanes
- ProGuide: Code Your Own States and Conditions
Styling
- ProSnippets: Content
- ProSnippets: Browse Dialog Filters
- ProConcepts: Project Content and Items
- ProConcepts: Custom Items
- ProGuide: Custom Items
- ProGuide: Custom browse dialog filters
- ArcGIS Pro TypeID Reference
- ProSnippets: Editing
- ProConcepts: Editing
- ProConcepts: COGO
- ProConcepts: Annotation Editing
- ProConcepts: Dimension Editing
- ProGuide: Editing Tool
- ProGuide: Sketch Tool With Halo
- ProGuide: Construction Tools with Options
- ProGuide: Annotation Construction Tools
- ProGuide: Annotation Editing Tools
- ProGuide: Knowledge Graph Construction Tools
- ProGuide: Templates
3D Analyst Data
Plugin Datasources
Topology
Linear Referencing
Object Model Diagram
- ProSnippets: Geometry
- ProSnippets: Geometry Engine
- ProConcepts: Geometry
- ProConcepts: Multipatches
- ProGuide: Building Multipatches
Relational Operations
- ProSnippets: Knowledge Graph
- ProConcepts: Knowledge Graph
- ProGuide: Knowledge Graph Construction Tools
Reports
- ProSnippets: Map Authoring
- ProSnippets: Annotation
- ProSnippets: Charts
- ProSnippets: Labeling
- ProSnippets: Renderers
- ProSnippets: Symbology
- ProSnippets: Text Symbols
- ProConcepts: Map Authoring
- ProConcepts: Annotation
- ProConcepts: Dimensions
- ProGuide: Tray buttons
- ProGuide: Custom Dictionary Style
- ProGuide: Geocoding
3D Analyst
CIM
Graphics
Scene
Stream
Voxel
- ProSnippets: Map Exploration
- ProSnippets: Custom Pane with Contents
- ProConcepts: Map Exploration
- ProGuide: Map Pane Impersonation
- ProGuide: TableControl
Map Tools
- ProGuide: Feature Selection
- ProGuide: Identify
- ProGuide: MapView Interaction
- ProGuide: Embeddable Controls
- ProGuide: Custom Pop-ups
- ProGuide: Dynamic Pop-up Menu
Network Diagrams
- ArcGIS Pro API Reference Guide
- ArcGIS Pro SDK (pro.arcgis.com)
- arcgis-pro-sdk-community-samples
- ArcGISPro Registry Keys
- ArcGIS Pro DAML ID Reference
- ArcGIS Pro Icon Reference
- ArcGIS Pro TypeID Reference
- ProConcepts: Distributing Add-Ins Online
- ProConcepts: Migrating to ArcGIS Pro
- FAQ
- Archived ArcGIS Pro API Reference Guides
- Dev Summit Tech Sessions