ArcGIS Pro 3.0 API Reference Guide
ArcGIS.Desktop.Layouts Namespace / GraphicFactory Class / CreateSimpleTextGraphic Method
The type of text graphic to create
The geometry for the resulting graphic
The text symbol to be used with the graphic (optional)
The text string (optional)
Example

In This Topic
    CreateSimpleTextGraphic Method (GraphicFactory)
    In This Topic
    Creates a text graphic based on the input geometry, symbol, and text. This method must be called on the MCT. Use QueuedTask.Run.
    Syntax
    Public Function CreateSimpleTextGraphic( _
       ByVal textType As TextType, _
       ByVal geometry As Geometry, _
       Optional ByVal textSymbol As CIMTextSymbol, _
       Optional ByVal text As String _
    ) As CIMTextGraphicBase

    Parameters

    textType
    The type of text graphic to create
    geometry
    The geometry for the resulting graphic
    textSymbol
    The text symbol to be used with the graphic (optional)
    text
    The text string (optional)

    Return Value

    Exceptions
    ExceptionDescription
    This method or property must be called within the lambda passed to QueuedTask.Run.
    empty or null geometry
    Remarks
    For:
    • TextType.PointText use a point
    • TextType.SplinedText use a polyline (straight or curved)
    • TextType.CircleParagraph use a circle (polygon)
    • TextType.EllipseParagraph use an ellipse (polygon)
    • TextType.RectangleParagraph use an envelope
    • TextType.PolygonParagraph use a polygon
    For TextType.PointText and TextType.SplinedText, cast the returned CIMTextGraphicBase to ArcGIS.Core.CIM.CIMTextGraphic. For all paragraph text types cast to ArcGIS.Core.CIM.CIMParagraphTextGraphic.
    Example
    Create Circle Text Graphic
    //Must be on QueuedTask.Run(() => { ...
    
    //Build geometry
    Coordinate2D center = new Coordinate2D(4.5, 4);
    var eabCir = new EllipticArcBuilderEx(center, 0.5, ArcOrientation.ArcClockwise);
    var cir = eabCir.ToSegment();
    
    var poly = PolygonBuilderEx.CreatePolygon(
      PolylineBuilderEx.CreatePolyline(cir, AttributeFlags.AllAttributes));
    
    //Set symbolology, create and add element to layout
    CIMTextSymbol sym = SymbolFactory.Instance.ConstructTextSymbol(
      ColorFactory.Instance.GreenRGB, 10, "Arial", "Regular");
    string text = "Circle, circle, circle";
    
    var graphic = GraphicFactory.Instance.CreateSimpleTextGraphic(
      TextType.CircleParagraph, poly, sym, text);
    
    //Make an element to add to GraphicsLayer or Layout
    //var ge = ElementFactory.Instance.CreateGraphicElement(container, graphic,
    //  "New Circle Text", true);
    Create Bezier Graphic
    //Must be on QueuedTask.Run(() => { ...
    
    //Build geometry
    Coordinate2D pt1 = new Coordinate2D(3.5, 7.5);
    Coordinate2D pt2 = new Coordinate2D(4.16, 8);
    Coordinate2D pt3 = new Coordinate2D(4.83, 7.1);
    Coordinate2D pt4 = new Coordinate2D(5.5, 7.5);
    var bez = new CubicBezierBuilderEx(pt1, pt2, pt3, pt4);
    var bezSeg = bez.ToSegment();
    Polyline bezPl = PolylineBuilderEx.CreatePolyline(bezSeg, AttributeFlags.AllAttributes);
    
    //Set symbolology, create and add element to layout
    CIMTextSymbol sym = SymbolFactory.Instance.ConstructTextSymbol(
          ColorFactory.Instance.BlackRGB, 24, "Comic Sans MS", "Regular");
    
    var graphic = GraphicFactory.Instance.CreateSimpleTextGraphic(
      TextType.SplinedText, bezPl, sym, "Splined text");
    
    //Make an element to add to GraphicsLayer or Layout
    //var ge = ElementFactory.Instance.CreateGraphicElement(container, graphic);
    Requirements

    Target Platforms: Windows 11, Windows 10, Windows 8.1

    See Also