ArcGIS Pro 3.2 API Reference Guide
ArcGIS.Desktop.Mapping Namespace / MappingExtensions Class / GetTemplates Method
The map member to retrieve templates from.
Example

In This Topic
    GetTemplates Method (MappingExtensions)
    In This Topic
    Gets all templates for a map member. This method must be called on the MCT. Use QueuedTask.Run.
    Syntax
    public static IList<EditingTemplate> GetTemplates( 
       MapMember mapMember
    )
    Public Shared Function GetTemplates( _
       ByVal mapMember As MapMember _
    ) As IList(Of EditingTemplate)

    Parameters

    mapMember
    The map member to retrieve templates from.

    Return Value

    A list of templates.
    Exceptions
    ExceptionDescription
    This method or property must be called within the lambda passed to QueuedTask.Run.
    Remarks
    If called on the MCT and templates are not yet loaded the templates will load and be returned. See also AreTemplatesLoaded
    Example
    Find table templates belonging to a standalone table
    ArcGIS.Desktop.Framework.Threading.Tasks.QueuedTask.Run(() =>
    {
      var map = ArcGIS.Desktop.Mapping.MapView.Active.Map;
      if (map == null)
        return;
      //Get a particular table template
      var tableTemplate = map.FindStandaloneTables("Address Points").FirstOrDefault()?.GetTemplate("Residences");
      //Get all the templates of a standalone table
      var ownersTableTemplates = map.FindStandaloneTables("Owners").FirstOrDefault()?.GetTemplates();
      var statisticsTableTemplates = MapView.Active.Map.GetStandaloneTablesAsFlattenedList().First(l => l.Name.Equals("Trading Statistics")).GetTemplates();
    });
    Hide or show editing tools on templates
    QueuedTask.Run(() =>
    {
      //hide all tools except line tool on layer
      var featLayer = MapView.Active.Map.FindLayers("Roads").First();
    
      var editTemplates = featLayer.GetTemplates();
      var newCIMEditingTemplates = new List<CIMEditingTemplate>();
    
      foreach (var et in editTemplates)
      {
        //initialize template by activating default tool
        et.ActivateDefaultToolAsync();
        var cimEditTemplate = et.GetDefinition();
        //get the visible tools on this template
        var allTools = et.ToolIDs.ToList();
        //add the hidden tools on this template
        allTools.AddRange(cimEditTemplate.GetExcludedToolIDs().ToList());
        //hide all the tools then allow the line tool
      
        //At 2.x -
        //allTools.AddRange(cimEditTemplate.GetExcludedToolDamlIds().ToList());
        allTools.AddRange(cimEditTemplate.GetExcludedToolIDs().ToList());
        
        //At 2.x - 
        //cimEditTemplate.SetExcludedToolDamlIds(allTools.ToArray());
        //cimEditTemplate.AllowToolDamlID("esri_editing_SketchLineTool");
        
        cimEditTemplate.SetExcludedToolIDs(allTools.ToArray());
        cimEditTemplate.AllowToolID("esri_editing_SketchLineTool");
        newCIMEditingTemplates.Add(cimEditTemplate);
      }
      //update the layer templates
      var layerDef = featLayer.GetDefinition() as CIMFeatureLayer;
      // Set AutoGenerateFeatureTemplates to false for template changes to stick
      layerDef.AutoGenerateFeatureTemplates = false;
      layerDef.FeatureTemplates = newCIMEditingTemplates.ToArray();
      featLayer.SetDefinition(layerDef);
    });
    Requirements

    Target Platforms: Windows 11, Windows 10

    ArcGIS Pro version: 3 or higher.
    See Also