ArcGIS Pro 3.7 API Reference Guide
ArcGIS.Core.CIM Namespace / CIMBasicFeatureLayer Class / AutoGenerateFeatureTemplates Property
Example

In This Topic
    AutoGenerateFeatureTemplates Property
    In This Topic
    Gets or sets a value indicating whether to automatically generate feature templates from the renderer.
    Syntax
    Public Property AutoGenerateFeatureTemplates As Boolean
    public bool AutoGenerateFeatureTemplates {get; set;}
    Remarks
    When this value is set to true, appropriate templates will be added to FeatureTemplates whenever the renderer is changed.
    Example
    Change Default Edit tool for a template
    await QueuedTask.Run(() =>
          {
            var templateName = "Distribution"; // name of the template to update
            var toolDamlPlugInID = "esri_editing_SketchTwoPointLineTool"; // DAML ID of the tool to set as default
            var toolContentGUID = "e2096d13-b437-4bc1-94ea-4494c3260f72"; // Example GUID, replace with actual GUID from DAML
                                                                          // retrieve the edit template form the layer by name
            var template = featureLayer?.GetTemplate(templateName) as EditingTemplate;
            // get the definition of the layer
            var layerDef = featureLayer?.GetDefinition() as CIMFeatureLayer;
            if (template == null || layerDef == null)
              return;
            if (template.DefaultToolID != toolDamlPlugInID)
            {
              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"
    
              //templateDef.ToolProgID = toolContentGUID;
              templateDef.DefaultToolGUID = toolContentGUID;
    
              // set the definition back to 
              template.SetDefinition(templateDef);
    
              // update the layer definition too
              if (updateLayerDef)
                featureLayer.SetDefinition(layerDef);
            }
          });
    Requirements

    Target Platforms: Windows 11 Home, Pro, Enterprise (64 bit)

    ArcGIS Pro version: 3.0 or higher.
    See Also