ArcGIS Pro 3.4 API Reference Guide
ArcGIS.Desktop.Mapping Namespace / MappingExtensions Class / GetTemplate Method
The map member containing the template.
The name of the template to be retrieved.
Example Version

GetTemplate Method
Gets a template by name for a map member. This method must be called on the MCT. Use QueuedTask.Run.
Syntax
public static EditingTemplate GetTemplate( 
   MapMember mapMember,
   string name
)

Parameters

mapMember
The map member containing the template.
name
The name of the template to be retrieved.

Return Value

The template. Null if the template doesn't exist on the map member..
Exceptions
ExceptionDescription
This method or property must be called within the lambda passed to QueuedTask.Run.
Example
Find edit template by name on a layer
ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() =>
{
  //get the templates
  var map = ArcGIS.Desktop.Mapping.MapView.Active.Map;
  if (map == null)
    return;

  var mainTemplate = map.FindLayers("main").FirstOrDefault()?.GetTemplate("Distribution");
  var mhTemplate = map.FindLayers("Manhole").FirstOrDefault()?.GetTemplate("Active");
});
Change Default Edit tool for a template
public Task ChangeTemplateDefaultToolAsync(ArcGIS.Desktop.Mapping.FeatureLayer flayer,
                  string toolContentGUID, string templateName)
{
  return ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() =>
  {

    // retrieve the edit template form the layer by name
    var template = flayer?.GetTemplate(templateName) as ArcGIS.Desktop.Editing.Templates.EditingTemplate;
    // get the definition of the layer
    var layerDef = flayer?.GetDefinition() as ArcGIS.Core.CIM.CIMFeatureLayer;
    if ((template == null) || (layerDef == null))
      return;

    if (template.DefaultToolID != this.ID)
    {
      bool updateLayerDef = false;
      if (layerDef.AutoGenerateFeatureTemplates)
      {
        layerDef.AutoGenerateFeatureTemplates = false;
        updateLayerDef = true;
      }

      // retrieve the CIM edit template definition
      var templateDef = template.GetDefinition();

      // assign the GUID from the tool DAML definition, for example
      // <tool id="TestConstructionTool_SampleSDKTool" categoryRefID="esri_editing_construction_polyline" ….>
      //   <tooltip heading="">Tooltip text<disabledText /></tooltip>
      //   <content guid="e58239b3-9c69-49e5-ad4d-bb2ba29ff3ea" />
      // </tool>
      // then the toolContentGUID would be "e58239b3-9c69-49e5-ad4d-bb2ba29ff3ea"

      //At 2.x -
      //templateDef.ToolProgID = toolContentGUID;
      templateDef.DefaultToolGUID = toolContentGUID;

      // set the definition back to 
      template.SetDefinition(templateDef);

      // update the layer definition too
      if (updateLayerDef)
        flayer.SetDefinition(layerDef);
    }
  });
}
Requirements

Target Platforms: Windows 11, Windows 10

ArcGIS Pro version: 3 or higher.
See Also