ArcGIS Pro 3.7 API Reference Guide
ArcGIS.Desktop.Editing Namespace / AnnotationProperties Class
Members Example

In This Topic
    AnnotationProperties Class
    In This Topic
    Provides access to the attributes of annotation features.
    Object Model
    AnnotationProperties ClassCIMColor ClassLayer ClassGeometry ClassCIMTextGraphic Class
    Syntax
    Public NotInheritable Class AnnotationProperties 
    public sealed class AnnotationProperties 
    Example
    Create Annotation Template
    // Creates a new annotation template for the specified annotation layer.
    await QueuedTask.Run(() =>
      {
        Inspector insp = null;
        // get the anno feature class
        var fc = annotationLayer.GetFeatureClass() as ArcGIS.Core.Data.Mapping.AnnotationFeatureClass;
    
        // get the feature class CIM definition which contains the labels, symbols
        var cimDefinition = fc.GetDefinition() as ArcGIS.Core.Data.Mapping.AnnotationFeatureClassDefinition;
        var labels = cimDefinition.GetLabelClassCollection();
        var symbols = cimDefinition.GetSymbolCollection();
    
        // make sure there are labels, symbols
        if (labels.Count == 0 || symbols.Count == 0)
          return;
    
        // find the label class required
        //   typically you would use a subtype name or some other characteristic
        // in this case lets just use the first one
    
        var label = labels[0];
    
        // each label has a textSymbol
        // the symbolName *should* be the symbolID to be used
        var symbolName = label.TextSymbol.SymbolName;
        int symbolID = -1;
        if (!int.TryParse(symbolName, out symbolID))
        {
          // int.TryParse fails - attempt to find the symbolName in the symbol collection
          foreach (var symbol in symbols)
          {
            if (symbol.Name == symbolName)
            {
              symbolID = symbol.ID;
              break;
            }
          }
        }
        // no symbol?
        if (symbolID == -1)
          return;
    
        // load the schema
        insp = new Inspector();
        insp.LoadSchema(annotationLayer);
    
        // ok to assign these fields using the inspector[fieldName] methodology
        //   these fields are guaranteed to exist in the annotation schema
        insp["AnnotationClassID"] = label.ID;
        insp["SymbolID"] = symbolID;
    
        // set up some additional annotation properties
        AnnotationProperties annoProperties = insp.GetAnnotationProperties();
        annoProperties.FontSize = 36;
        annoProperties.TextString = "My Annotation feature";
        annoProperties.VerticalAlignment = VerticalAlignment.Top;
        annoProperties.HorizontalAlignment = HorizontalAlignment.Justify;
    
        insp.SetAnnotationProperties(annoProperties);
    
        var tags = new[] { "Annotation", "tag1", "tag2" };
    
        // use daml-id rather than guid
        string defaultTool = "esri_editing_SketchStraightAnnoTool";
    
        // tool filter is the tools to filter OUT
        var toolFilter = new[] { "esri_editing_SketchCurvedAnnoTool" };
    
        // create a new template 
        var newTemplate = annotationLayer.CreateTemplate("new annotation template", "description", insp, defaultTool, tags, toolFilter);
      });
    Annotation Construction Tool
    //In your config.daml...set the categoryRefID
    //<tool id="..." categoryRefID="esri_editing_construction_annotation" caption="Create Anno" ...>
    
    //Sketch type Point or Line or BezierLine in the constructor...
    public class ProSnippetAnnotationConstructionTool : MapTool
    {
      public ProSnippetAnnotationConstructionTool()
      {
        IsSketchTool = true;
        UseSnapping = true;
        SketchType = SketchGeometryType.Point;
      }
    
      /// <summary>
      /// Handles the completion of a sketch operation and creates an annotation feature based on the provided geometry.
      /// </summary>
      protected async override Task<bool> OnSketchCompleteAsync(Geometry geometry)
      {
        if (CurrentTemplate == null || geometry == null)
          return false;
        // Create an edit operation
        var createOperation = new EditOperation
        {
          Name = string.Format("Create {0}", CurrentTemplate.Layer.Name),
          SelectNewFeatures = true
        };
        var insp = CurrentTemplate.Inspector;
        var result = await QueuedTask.Run(() =>
        {
          // get the annotation properties class
          AnnotationProperties annoProperties = insp.GetAnnotationProperties();
          // set custom annotation properties
          annoProperties.TextString = "my custom text";
          annoProperties.Color = ColorFactory.Instance.RedRGB;
          annoProperties.FontSize = 24;
          annoProperties.FontName = "Arial";
          annoProperties.HorizontalAlignment = HorizontalAlignment.Right;
          annoProperties.Shape = geometry;
          // assign annotation properties back to the inspector
          insp.SetAnnotationProperties(annoProperties);
          // Queue feature creation
          createOperation.Create(CurrentTemplate.Layer, insp);
          if (!createOperation.IsEmpty)
          {
            // Execute the operation
            return createOperation.Execute(); //Execute and ExecuteAsync will return true if the operation was successful and false if not
          }
          else
            return false;
        });
        return result;
      }
    }
    Inheritance Hierarchy

    System.Object
       ArcGIS.Desktop.Editing.AnnotationProperties

    Requirements

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

    ArcGIS Pro version: 3.0 or higher.
    See Also