ArcGIS Pro 3.7 API Reference Guide
ArcGIS.Core.Geometry Namespace / GeometryEngine Class / Rotate Method
The geometry to rotate. If the geometry is an Envelope, then it will be converted to a polygon.
The origin around which the geometry will be rotated.
The rotation angle in radians.
Example

In This Topic
    Rotate Method (GeometryEngine)
    In This Topic
    Rotates the geometry about the specified origin point.
    Syntax
    Public Function Rotate( _
       ByVal geometry As Geometry, _
       ByVal origin As MapPoint, _
       ByVal rotationAngle As Double _
    ) As Geometry

    Parameters

    geometry
    The geometry to rotate. If the geometry is an Envelope, then it will be converted to a polygon.
    origin
    The origin around which the geometry will be rotated.
    rotationAngle
    The rotation angle in radians.

    Return Value

    The rotated geometry. If the input geometry is an Envelope, then a polygon is returned. If the input geometry is empty, then an empty geometry is returned.
    Exceptions
    ExceptionDescription
    Either geometry or origin or both are null.
    The method is not implemented for GeometryBag.
    Incompatible spatial references between the input geometries.
    Example
    Rotate a MapPoint
    {
      MapPoint pt = MapPointBuilderEx.CreateMapPoint(1.0, 3.0);
      MapPoint rotatePt = MapPointBuilderEx.CreateMapPoint(3.0, 3.0);
    
      Geometry result = GeometryEngine.Instance.Rotate(pt, rotatePt, Math.PI / 2);
    }
    // result point is (3, 1)
    Rotate a Polyline
    {
      // rotate a polyline
    
      MapPoint fixedPt = MapPointBuilderEx.CreateMapPoint(3.0, 3.0);
    
      List<MapPoint> pts =
      [
        MapPointBuilderEx.CreateMapPoint(1.0, 1.0),
      MapPointBuilderEx.CreateMapPoint(1.0, 5.0),
      MapPointBuilderEx.CreateMapPoint(5, 5),
      MapPointBuilderEx.CreateMapPoint(5.0, 1.0),
    ];
      polyline = PolylineBuilderEx.CreatePolyline(pts);
    
      Polyline rotated = GeometryEngine.Instance.Rotate(polyline, fixedPt, Math.PI / 4) as Polyline;  // rotate 45 deg
    }
    Rotate or Move the Annotation
    {
      var oid = 1; //ObjectID of the annotation feature to modify
                   // Note: QueuedTask is required to access the AnnotationFeature
      {
        //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, oid);
        //var shape = insp["SHAPE"] as Polygon;
        //...wrong shape...
    
        //Instead, we must get the TextGraphic from the anno feature.
        //The TextGraphic shape will be the anno baseline...
        QueryFilter qf = new QueryFilter()
        {
          WhereClause = "OBJECTID = 1"
        };
    
        //annotationLayer is ~your~ Annotation layer
    
        using var rowCursor = annotationLayer.Search(qf);
        if (rowCursor.MoveNext())
        {
          using (var annoFeature = rowCursor.Current as
          ArcGIS.Core.Data.Mapping.AnnotationFeature)
          {
            var graphic = annoFeature.GetGraphic();
            var textGraphic = graphic as CIMTextGraphic;
            var textLine = textGraphic.Shape as Polyline;
            // rotate the shape 90 degrees
            var origin = GeometryEngine.Instance.Centroid(textLine);
            Geometry rotatedPolyline = GeometryEngine.Instance.Rotate(textLine, origin, System.Math.PI / 2);
            //Move the line 5 "units" in the x and y direction
            //GeometryEngine.Instance.Move(textLine, 5, 5);
    
            EditOperation op = new EditOperation();
            op.Name = "Change annotation angle";
            op.Modify(annotationLayer, oid, rotatedPolyline);
            op.Execute();
          }
        }
      }
    }
    Requirements

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

    ArcGIS Pro version: 3.0 or higher.
    See Also