Build a feature construction tool

This tutorial demonstrates how to create an ArcGIS Pro feature construction tool.

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.

The Pro SDK provides a construction tool template that goes beyond a map tool to assist developers creating a new tool, with placeholders for your own feature construction code.

In this tutorial, you will use C# to create a new polygon feature construction tool, which creates a polygon with a buffer distance of your specification.

Prerequisites

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. Name the add-in project "ConstructionTool".

Create a new Pro construction tool and edit DAML

  1. Right-click the project and choose Add > New Item. From the ArcGIS Pro Add-ins group > list of item templates, select ArcGIS Pro Construction Tool .

  2. Name the new class file BufferPolygonTool.cs and then click Add to close the dialog box.

  3. Open the Config.daml file and modify the tool item as follows:

    Use dark colors for code blocksCopy
    1
    2
    3
    4
    5
    6
    7
    8
    9
     <tool id="ConstructionTool_BufferPolygonTool"
           categoryRefID="esri_editing_construction_polygon"
           caption="Create Buffer Polygon"
           className="BufferPolygonTool"
           loadOnClick="true"
           smallImage="pack://application:,,,/ArcGIS.Desktop.Resources;component/Images/GenericButtonRed16.png"
           largeImage="pack://application:,,,/ArcGIS.Desktop.Resources;component/Images/GenericButtonRed32.png">
         <tooltip heading="Create Buffer Polygon"> Create polygon with a buffer distance.<disabledText /></tooltip>
     </tool>

Update your construction tool class code

  1. Open the BufferPolygonTool.cs file and modify the BufferPolygonTool constructor method as follows:

    Use dark colors for code blocksCopy
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
          public BufferPolygonTool()
          {
             IsSketchTool = true;
             UseSnapping = true;
             // Select the type of construction tool you wish to implement.
             // Make sure that the tool is correctly registered with the correct component category type in the daml
             // SketchType = SketchGeometryType.Point;
             // SketchType = SketchGeometryType.Line;
             SketchType = SketchGeometryType.Polygon;
             //Gets or sets whether the sketch is for creating a feature and should use the CurrentTemplate.
             UsesCurrentTemplate = true;
             //Gets or sets whether the tool supports firing sketch events when the map sketch changes.
             //Default value is false.
             FireSketchEvents = true;
          }
  2. Modify the OnSketchCompleteAsync method as follows:

    Use dark colors for code blocksCopy
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
       private double BufferDistance = 200;
    
       protected override Task<bool> OnSketchCompleteAsync(Geometry geometry)
       {
           if (CurrentTemplate == null || geometry == null)
               return Task.FromResult(false);
    
           Geometry bufferedGeometry = GeometryEngine.Instance.Buffer(geometry, BufferDistance);
    
           // Create an edit operation
           var createOperation = new EditOperation();
           createOperation.Name = string.Format("Create {0}", CurrentTemplate.Layer.Name);
           createOperation.SelectNewFeatures = true;
    
           // Queue feature creation
           createOperation.Create(CurrentTemplate, bufferedGeometry);
    
           // Execute the operation
           return createOperation.ExecuteAsync();
       }

Test your construction tool

  1. Rebuild your solution and fix any compilation errors.

  2. Click Start to begin debugging which will start ArcGIS Pro.

  3. Open the Pro project from the Pro SDK sample data installation, which is installed by default in: C:\Data\FeatureTest\FeatureTest.aprx.

  4. Once the project is open, zoom into an area where you would like to create your new polygon features. Zooming in on a park or the streets of a small neighborhood can be a good reference scale for testing.

  5. Click the Edit tab and then click Create in the Features group to show the Create Features pane.

  6. In the Create Features pane, review the list of available feature layers and then click on the symbol for TestPolygons to display the list of feature construction tools below it. The last tool on the bottom right, which should be visible as a small red button, is your new construction tool.

  7. Hover over the tool to confirm your caption and tooltip code from editing of Config.daml is working.

  8. Click the tool to activate it, and then sketch a simple polygon by clicking the vertices points.

  9. Double-click to finish your sketch. You should see your new feature created with your buffer distance applied.

What's Next?

Learn how to use additional ArcGIS Pro SDK for .NET features in these tutorials:

Your browser is no longer supported. Please upgrade your browser for the best experience. See our browser deprecation post for more details.