Overview

You will learn: 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 configurations that provide users with custom functionality specific to their organization or industry.

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

In this lab, you will use C# to create a new polygon feature construction tool which creates the polygon with a buffer distance which you specify.

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 and then from the ArcGIS Pro Add-ins group select ArcGIS Pro Construction Tool from the list of item templates. Name the new class file "BufferPolygonTool.cs" and press Add to close the dialog box.

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

     <tool id="ConstructionTool_BufferPolygonTool"
           categoryRefID="esri_editing_construction_polygon"
           caption="Create Buffer Polygon"
           className="BufferPolygonTool"
           loadOnClick="true"
           smallImage="Images\GenericButtonRed16.png"
           largeImage="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 BufferCircleTool constructor method as follows:

       public BufferCircleTool()
       {
           IsSketchTool = true;
           UseSnapping = true;
           // SketchType = SketchGeometryType.Point;
           // SketchType = SketchGeometryType.Line;
           SketchType = SketchGeometryType.Polygon;
       }
    
  2. Modify the OnSketchCompleteAsync method as follows:

       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. Click Start to begin debugging which will start ArcGIS Pro.

    1. Open the Pro project from the Pro SDK sample data installation which should be located at: C:\Data\FeatureTest\FeatureTest.aprx.
    2. Once the project is open, zoom into an area 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.
    3. Click the Edit tab and then press the Create button in the Features group to show the Create Features pane.
  2. 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.

    1. Hover over the tool to confirm your caption and tooltip code from editing of Config.daml is working.
    2. Click the tool to activate it, and then sketch a simple polygon by clicking the vertices points.
    3. Double-click to finish your sketch. You should see your new feature created with your buffer distance applied.

Congratulations, you're done!

Check out and compare with our completed solution project.

Challenge

Review the online documentation

Read more information about feature editing and construction in the ProConcepts Editing document, and also review the ProGuide on building construction tools with options.

Try a community sample

Download and try the community sample ConstructionToolWithOptions referenced in the ProGuide above.

Review the API reference

Review the Pro SDK API reference and find the EditOperation class for more information, methods and additional behavior.