This document is archived and information here might be outdated.  Recommended version.


How to work with IEllipticArc properties (ArcObjects .NET 10.6 SDK)
ArcObjects Help for .NET developers > Developing with ArcGIS > Learning ArcObjects > Managing data > Working with geometry > Working with curves, segments, and vertices > How to work with IEllipticArc properties (ArcObjects .NET 10.6 SDK)

How to work with IEllipticArc properties


Working with IEllipticArc properties

Do the following steps to work with IEllipticArc properties:
  1. Create three points with the names of startPoint, centerPoint, and endPoint.
  2. Define a new elliptic arc using centerPoint, startPoint, and endPoint. Now, you have an elliptic arc to work with and the IEllipticArc interface to get the various properties of the elliptic arc, such as CenterPoint, FromAngle, CentralAngle, ToAngle, IsLine, IsPoint, IsMinor, IsCounterClockwise, and so on. A method is also provided to display the created elliptic arc in ArcMap.
The following code example shows how to work with IEllipticArc properties:
[C#]
public void ShowEllipticArcProperties()
{
    // Get the application handle and the display.
    //Use IEllipticArc.PutCoords to input the center, start, and end points to create an EllipticArc.
    IPoint startPoint=new PointClass();
    startPoint.PutCoords(100, 100);
    IPoint centerPoint=new PointClass();
    centerPoint.PutCoords(250, 100);
    IPoint endPoint=new PointClass();
    endPoint.PutCoords(400, 100);
    IEllipticArc ellipticArc=new EllipticArcClass();
    //Draw an elliptic arc with a solid line symbol.
    ellipticArc.PutCoords(false, centerPoint, startPoint, endPoint, Math.PI, 1 / 3,
        esriArcOrientation.esriArcClockwise);
    //Display the arc.
    ISimpleLineSymbol symbol=new SimpleLineSymbol();
    symbol.Style=esriSimpleLineStyle.esriSLSDot;
    IMxApplication mxApplication=m_application as IMxApplication;
    IDisplay display=mxApplication.Display;
    DisplayArc(mxApplication, display as IScreenDisplay, ellipticArc, symbol as
        ISymbol);
    //Use IEllipticArc.QueryCoords to get the statistics of the elliptic arc.
    System.Windows.Forms.MessageBox.Show("The statistics of the Elliptic arc are: " 
        + "\n" + "Center Point : " + "\n" + " X coord: " + ellipticArc.CenterPoint.X
        + "\n" + " Y coord: " + ellipticArc.CenterPoint.Y + "\n" + "IsCircular: " +
        ellipticArc.IsCircular + "\n" + "From Angle: " + ellipticArc.get_FromAngle
        (false) + "\n" + "Central Angle: " + ellipticArc.CentralAngle + "\n" + 
        "To Angle: " + ellipticArc.get_ToAngle(false) + "\n" + "IsLine: " +
        ellipticArc.IsLine + "\n" + "IsPoint: " + ellipticArc.IsPoint + "\n" + 
        "IsMinor: " + ellipticArc.IsMinor + "\n" + "IsCCW: " +
        ellipticArc.IsCounterClockwise);
}

private void DisplayArc(IMxApplication mxApplication, IScreenDisplay sreenDisplay,
    IEllipticArc ellipticArc, ISymbol lineSymbol)
{
    short oldActiveCache=sreenDisplay.ActiveCache;
    //Add the new arc to a segment collection.
    ISegment segment=ellipticArc as ISegment;
    ISegmentCollection polyline=new Polyline()as ISegmentCollection;
    object Missing=Type.Missing;
    polyline.AddSegment(segment, ref Missing, ref Missing);
    sreenDisplay.ActiveCache=(short)esriScreenCache.esriNoScreenCache;
    sreenDisplay.StartDrawing(mxApplication.Display.hDC, (short)
        esriScreenCache.esriNoScreenCache);
    sreenDisplay.SetSymbol(lineSymbol);
    sreenDisplay.DrawPolyline(polyline as IGeometry);
    sreenDisplay.FinishDrawing();
    sreenDisplay.ActiveCache=oldActiveCache;
}
[VB.NET]
Public Sub Test()
    ' Get the application handle and the display.
    Dim pMxApp As IMxApplication, pSDisplay As IScreenDisplay
    pMxApp=MxApplication
    pSDisplay=pMxApp.Display
    'Use IEllipticArc.PutCoords to input the center, start, and end points to create an EllipticArc.
    Dim pCPt As IPoint, pSPt As IPoint, pEPt As IPoint
    pSPt=eCreatePoint(100, 100)
    pCPt=eCreatePoint(250, 100)
    pEPt=eCreatePoint(400, 100)
    Dim pEllipticArc As IEllipticArc
    pEllipticArc=New EllipticArc
    'Draw an elliptic arc with a solid line symbol.
    pEllipticArc.PutCoords(False, pCPt, pSPt, pEPt, 3.14, 1 / 3, esriArcOrientation.esriArcClockwise)
    DisplayArc(pMxApp, pSDisplay, pEllipticArc, esriSimpleLineStyle.esriSLSSolid)
    'Use IEllipticArc.QueryCoords to get the statistics of the elliptic arc.
    Dim pEArc As IEllipticArc
    pEArc=pEllipticArc
    Dim NL As String, TB As String
    NL=Chr(13) & Chr(10) ' Define newline.
    TB=Chr(9) ' Define tab
    MsgBox("The statistics of the Elliptic arc are: " + NL + _
           "Center Point : " + NL + _
           "  X coord: " + TB + Str(pEArc.CenterPoint.x) + NL + _
           "  Y coord: " + TB + Str(pEArc.CenterPoint.y) + NL + _
           "IsCircular: " + TB + Str(pEArc.IsCircular) + NL + _
           "From Angle: " + TB + Str(pEArc.fromAngle(False)) + NL + _
           "Central Angle: " + TB + Str(pEArc.CentralAngle) + NL + _
           "To Angle: " + TB + Str(pEArc.ToAngle(False)) + NL + _
           "IsLine: " + TB + Str(pEArc.IsLine) + NL + _
           "IsPoint: " + TB + Str(pEArc.IsPoint) + NL + _
           "IsMinor: " + TB + Str(pEArc.isMinor) + NL + _
           "IsCCW: " + TB + Str(pEArc.IsCounterClockwise))
End Sub


Public Function eSimpleLine(ByVal currStyle) As ISimpleLineSymbol
    eSimpleLine=New SimpleLineSymbol
    eSimpleLine.Style=currStyle
End Function


Public Sub DisplayArc(ByVal pMxApp As IMxApplication, ByVal pSDisplay As IScreenDisplay, ByVal pEArc As IEllipticArc, ByVal currStyle)
    Dim lOldActiveCache As Long
    lOldActiveCache=pSDisplay.ActiveCache
    'Add the new arc to a segment collection.
    Dim pSeg As ISegment
    pSeg=pEArc
    Dim pPolyline As ISegmentCollection
    pPolyline=New Polyline
    pPolyline.AddSegment(pSeg)
    With pSDisplay
        .ActiveCache=esriScreenCache.esriNoScreenCache ' esriNoScreenCache=-1.
        .StartDrawing(pMxApp.Display.hDC, esriScreenCache.esriNoScreenCache)
        .SetSymbol(eSimpleLine(currStyle))
        .DrawPolyline(pPolyline)
        .FinishDrawing()
        .ActiveCache=lOldActiveCache
    End With
End Sub


Public Function eCreatePoint(ByVal x As Double, ByVal y As Double) As IPoint
    eCreatePoint=New Point
    eCreatePoint.PutCoords(x, y)
End Function






To use the code in this topic, reference the following assemblies in your Visual Studio project. In the code files, you will need using (C#) or Imports (VB .NET) directives for the corresponding namespaces (given in parenthesis below if different from the assembly name):
Development licensing Deployment licensing
ArcGIS Desktop Basic ArcGIS Desktop Basic
ArcGIS Desktop Standard ArcGIS Desktop Standard
ArcGIS Desktop Advanced ArcGIS Desktop Advanced
Engine Developer Kit Engine