ArcGIS Pro 3.8 API Reference Guide
ArcGIS.Desktop.Editing Namespace / AnnotationProperties Class / Shape Property
Example

In This Topic
    Shape Property (AnnotationProperties)
    In This Topic
    Gets and sets the text baseline shape.
    Syntax
    public Geometry Shape {get; set;}
    Public Property Shape As Geometry
    Remarks
    The shape geometry represents the reference point or line for the annotation. Supported geometry types include point, line, multipoint and geometryBag.
    Example
    Programmatically Create an Annotation Feature
    await QueuedTask.Run(() =>
      {
        // annotationLayer is ~your~ Annotation layer...
        // annotationPoint is ~your~ Annotation's location geometry ...
        var op = new EditOperation();
        // Use the inspector
        var insp = new Inspector();
        insp.LoadSchema(annotationLayer);
        // get the annotation properties from the inspector
        AnnotationProperties annoProperties = insp.GetAnnotationProperties();
        // change the annotation text
        annoProperties.TextString = DateTime.Now.ToLongTimeString();
        // change font color to green
        annoProperties.Color = ColorFactory.Instance.GreenRGB;
        // change the horizontal alignment
        annoProperties.HorizontalAlignment = HorizontalAlignment.Center;
        annoProperties.Shape = annotationPoint;
        // set the annotation properties back on the inspector
        insp.SetAnnotationProperties(annoProperties);
        // create the annotation
        op.Create(annotationLayer, insp);
        if (!op.IsEmpty)
        {
          var result = op.Execute(); //Execute and ExecuteAsync will return true if the operation was successful and false if not
        }
      });
    Modify Annotation Shape
    // Modifies the geometry of an annotation feature in the specified annotation layer.
    await QueuedTask.Run(() =>
    {
      //Don't use 'Shape'....Shape is the bounding box of the annotation text. This is NOT what you want...
      //
      //var insp = new Inspector();
      //insp.Load(annotationLayer, objectId);
      //var shape = insp["SHAPE"] as Polygon;
      //...wrong shape...
      //Instead, we must use the AnnotationProperties
      //annotationLayer is ~your~ Annotation layer
      var insp = new Inspector();
      insp.Load(annotationLayer, objectId);
      AnnotationProperties annoProperties = insp.GetAnnotationProperties();
      var shape = annoProperties.Shape;
      if (shape.GeometryType != GeometryType.GeometryBag)
      {
        var newGeometry = GeometryEngine.Instance.Move(shape, 10, 10);
        annoProperties.Shape = newGeometry;
        insp.SetAnnotationProperties(annoProperties);
        EditOperation op = new EditOperation
        {
          Name = "Change annotation angle"
        };
        op.Modify(insp);
        if (!op.IsEmpty)
        {
          var result = op.Execute(); //Execute and ExecuteAsync will return true if the operation was successful and false if not
        }
      }
    });
    Requirements

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

    ArcGIS Pro version: 3.0 or higher.
    See Also