ArcObjects Library Reference  (Geometry)    

ICurve_Property_Example

[Visual Basic 6.0]
 ' The example shows how to get the ICurve properties for a
 ' selected polygon in an ArcMap edit session.
         
 Public Sub t_ICurve_polygon()
   Dim pID As New UID
   pID = "esriEditor.editor"
   Dim pEditor As IEditor
   Dim pApp As IApplication
   Set pApp = Application
   Set pEditor = pApp.FindExtensionByCLSID(pID)
   
   If   pEditor.SelectionCount <> 1 Then
     MsgBox "select one polygon"
     Exit Sub
   End If
   
   Dim pEnumFeat As IEnumFeature
   Dim pFeature As IFeature
   Dim i As Long
 
   Set pEnumFeat = pEditor.EditSelection
 
   Dim pCurve As ICurve
 
   Set pFeature = pEnumFeat.Next
 
   While Not pFeature Is Nothing
     If pFeature.Shape.GeometryType = esriGeometryPolygon Then
       Set pCurve = pFeature.Shape
       MsgBox "+++Polygon::ICurve properties..." & vbCrLf _
         & "Curve.Length = " & pCurve.Length & vbCrLf _
         & "Curve.IsClosed = " & pCurve.IsClosed _
         & "Curve.FromPoint.X = " & pCurve.FromPoint.X & vbCrLf _
         & "Curve.FromPoint.Y = " & pCurve.FromPoint.Y & vbCrLf _
         & "Curve.ToPoint.X = " & pCurve.ToPoint.X & vbCrLf _
         & "Curve.ToPoint.Y = " & pCurve.ToPoint.Y
     End If
     Set pFeature = pEnumFeat.Next
   Wend
 
 End Sub

[C#]
//The example shows how to get the ICurve properties for a
//selected polygon in an ArcMap edit session.
public void GetProperties()
{
  UID editorUID = new UIDClass();
  editorUID.Value = "esriEditor.editor";
  IEditor editor = m_application.FindExtensionByCLSID(editorUID) as IEditor;
  if (editor.SelectionCount != 1)
  {
    System.Windows.Forms.MessageBox.Show("Start editing and select exactly one polygon");
    return;
  }
  IEnumFeature featureEnumeration = editor.EditSelection;
  IFeature currentFeature = featureEnumeration.Next();
  while (currentFeature != null)
  {
    if (currentFeature.Shape.GeometryType == esriGeometryType.esriGeometryPolygon)
    {
      ICurve curve = currentFeature.Shape as ICurve;
      System.Windows.Forms.MessageBox.Show("Polygon::ICurve properties..." + "\n" +
      "Curve.Length = " + curve.Length + "\n" +
      "Curve.IsClosed = " + curve.IsClosed + "\n" +
      "Curve.FromPoint.X = " + curve.FromPoint.X + "\n" +
      "Curve.FromPoint.Y = " + curve.FromPoint.Y + "\n" +
      "Curve.ToPoint.X = " + curve.ToPoint.X + "\n" +
      "Curve.ToPoint.Y = " + curve.ToPoint.Y
      );
      currentFeature = featureEnumeration.Next();
    }
  }
}

[Visual Basic .NET, C++]
No example is available for Visual Basic .NET or C++. To view a Visual Basic 6.0 or C# example, click the Language Filter button Language Filter in the upper-left corner of the page.