ArcGIS Pro 3.2 API Reference Guide
ArcGIS.Core.Geometry Namespace / EllipticArcBuilderEx Class / ToSegment Method
Example

In This Topic
    ToSegment Method (EllipticArcBuilderEx)
    In This Topic
    Returns an EllipticArcSegment instance representing the current state of the builder.
    Syntax
    public new EllipticArcSegment ToSegment()
    Public Shadows Function ToSegment() As EllipticArcSegment

    Return Value

    An EllipticArc segment.
    Example
    Construct a Circular Arc - using an interior point
    // Construct a circular arc from (2, 1) to (1, 2) with interior pt (1 + sqrt(2)/2, 1 + sqrt(2)/2).
    // Use a builderEx convenience method or use a builderEx constructor.
    
    MapPoint fromPt = MapPointBuilderEx.CreateMapPoint(2, 1);
    MapPoint toPt = MapPointBuilderEx.CreateMapPoint(1, 2);
    Coordinate2D interiorPt = new Coordinate2D(1 + Math.Sqrt(2) / 2, 1 + Math.Sqrt(2) / 2);
    
    // BuilderEx convenience methods don't need to run on the MCT.
    EllipticArcSegment circularArc = EllipticArcBuilderEx.CreateCircularArc(fromPt, toPt, interiorPt);
    
    // BuilderEx constructors don't need to run on the MCT.
    EllipticArcBuilderEx eab = new EllipticArcBuilderEx(fromPt, toPt, interiorPt);
    // do something with the builder
    
    EllipticArcSegment anotherCircularArc = eab.ToSegment();
    
    Construct a Circular Arc - using a chord length and bearing
    // Construct a circular arc counterclockwise from (2, 1) to (1, 2) such that the embedded 
    // circle has center point at (1, 1) and radius = 1.
    // Use a builderEx convenience method or use a builderEx constructor.
    
    MapPoint fromPt = MapPointBuilderEx.CreateMapPoint(2, 1, SpatialReferences.WGS84);
    double chordLength = Math.Sqrt(2);
    double chordBearing = 3 * Math.PI / 4;
    double radius = 1;
    ArcOrientation orientation = ArcOrientation.ArcCounterClockwise;
    MinorOrMajor minorOrMajor = MinorOrMajor.Minor;
    
    // BuildeEx convenience methods don't need to run on the MCT.
    EllipticArcSegment circularArc = EllipticArcBuilderEx.CreateCircularArc(fromPt, chordLength, chordBearing, radius, orientation, minorOrMajor);
    
    // BuilderEx constructors don't need to run on the MCT either.
    EllipticArcBuilderEx cab = new EllipticArcBuilderEx(fromPt, chordLength, chordBearing, radius, orientation, minorOrMajor);
    // do something with the builder
    
    EllipticArcSegment anotherCircularArc = cab.ToSegment();
    
    Construct a Circular Arc - using a center point, angle and radius
    // Construct a circular arc with center point at (0, 0), from angle = 0, 
    // central angle = pi/2, radius = 1.
    // Use a builderEx convenience method or use a builderEx constructor.
    
    SpatialReference sr4326 = SpatialReferences.WGS84;
    Coordinate2D centerPt = new Coordinate2D(0, 0);
    double fromAngle = 0;
    double centralAngle = Math.PI / 2;
    double radius = 1;
    
    // BuilderEx convenience methods don't need to run on the MCT.
    EllipticArcSegment circularArc = EllipticArcBuilderEx.CreateCircularArc(fromAngle, centralAngle, centerPt, radius, sr4326);
    
    // BuilderEx constructors don't need to run on the MCT.
    EllipticArcBuilderEx cab = new EllipticArcBuilderEx(fromAngle, centralAngle, centerPt, radius, sr4326);
    EllipticArcSegment otherCircularArc = cab.ToSegment();
    
    Create_circle
    //Create a circle graphic element using a simple line and fill styles.
    
    //Construct on the worker thread
    await QueuedTask.Run(() =>
    {
      //Build geometry
      Coordinate2D center = new Coordinate2D(2, 4);
      //At 2.x - EllipticArcBuilder eabCir = new EllipticArcBuilder(center, 0.5, esriArcOrientation.esriArcClockwise);
      var eabCir = new EllipticArcBuilderEx(center, 0.5, ArcOrientation.ArcClockwise);
      EllipticArcSegment cir = eabCir.ToSegment();
    
      //Set symbolology, create and add element to layout
      CIMStroke outline = SymbolFactory.Instance.ConstructStroke(ColorFactory.Instance.BlackRGB, 2.0, SimpleLineStyle.Dash);
      CIMPolygonSymbol circleSym = SymbolFactory.Instance.ConstructPolygonSymbol(ColorFactory.Instance.RedRGB, SimpleFillStyle.Solid, outline);
      //At 2.x - GraphicElement cirElm = LayoutElementFactory.Instance.CreateCircleGraphicElement(layout, cir, circleSym);
      //         cirElm.SetName("New Circle");
    
      var polyLine = PolylineBuilderEx.CreatePolyline(cir);
      GraphicElement cirElm = ElementFactory.Instance.CreateGraphicElement(layout, polyLine, circleSym, "New Circle");
    });
    Create_ellipse
    //Create an ellipse graphic with simple line and fill styles.
    
    //Construct on the worker thread
    await QueuedTask.Run(() =>
    {
      //Build geometry
      Coordinate2D center = new Coordinate2D(2, 2.75);
      //At 2.x - EllipticArcBuilder eabElp = new EllipticArcBuilder(center, 0, 1, 0.45, esriArcOrientation.esriArcClockwise);
      var eabElp = new EllipticArcBuilderEx(center, 0, 1, 0.45, ArcOrientation.ArcClockwise);
      EllipticArcSegment ellipse = eabElp.ToSegment();
    
      //Set symbolology, create and add element to layout
      CIMStroke outline = SymbolFactory.Instance.ConstructStroke(ColorFactory.Instance.GreenRGB, 2.0, SimpleLineStyle.Dot);
      CIMPolygonSymbol ellipseSym = SymbolFactory.Instance.ConstructPolygonSymbol(ColorFactory.Instance.GreyRGB, SimpleFillStyle.Vertical, outline);
      //At 2.x - GraphicElement elpElm = LayoutElementFactory.Instance.CreateEllipseGraphicElement(layout, ellipse, ellipseSym);
      //         elpElm.SetName("New Ellipse");
    
      var polyLine = PolylineBuilderEx.CreatePolyline(ellipse);
      GraphicElement elpElm = ElementFactory.Instance.CreateGraphicElement(layout, polyLine, ellipseSym, "New Ellipse");
    });
    Create Circle Text Element
    //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";
    
    GraphicElement cirTxtElm = ElementFactory.Instance.CreateTextGraphicElement(
      container, TextType.CircleParagraph, poly, sym, text, "New Circle Text", false);
    
    Create Ellipse Text Element
    //Must be on QueuedTask.Run(() => { ...
    
    //Build geometry
    Coordinate2D center = new Coordinate2D(4.5, 2.75);
    var eabElp = new EllipticArcBuilderEx(center, 0, 1, 0.45, ArcOrientation.ArcClockwise);
    var ellipse = eabElp.ToSegment();
    
    var poly = PolygonBuilderEx.CreatePolygon(
      PolylineBuilderEx.CreatePolyline(ellipse, AttributeFlags.AllAttributes));
    
    //Set symbolology, create and add element to layout
    CIMTextSymbol sym = SymbolFactory.Instance.ConstructTextSymbol(
                          ColorFactory.Instance.BlueRGB, 10, "Arial", "Regular");
    string text = "Ellipse, ellipse, ellipse";
    
    GraphicElement ge = ElementFactory.Instance.CreateTextGraphicElement(
      container, TextType.PolygonParagraph, poly, sym, text, "New Ellipse Text", false);
    
    Requirements

    Target Platforms: Windows 11, Windows 10

    ArcGIS Pro version: 3 or higher.
    See Also