ArcObjects Library Reference  (Geometry)    

ReverseOrientation_Example

[Visual Basic 6.0]
 ' The example shows how to reverse the order of points for
 ' a Curve. Run the script from an ArcMap edit session and select
 ' features to reverse the order of points.
 
 Public Sub t_ICurve_ReverseOrientation()
   Dim pID As New UID
   pID = "esriEditor.editor"
   Dim pEditor As IEditor
   Dim pApp As IApplication
   Set pApp = MxApplication
   Set pEditor = pApp.FindExtensionByCLSID(pID)
   
   If pEditor.SelectionCount < 1 Then
     MsgBox "select at least one feature"
     Exit Sub
   End If
   
   Dim pEnumFeat As IEnumFeature
   Dim pFeature As IFeature
 
   Set pEnumFeat = pEditor.EditSelection
 
   Dim pCurve As ICurve
   Dim pPtColl As IPointCollection
 
   Set pFeature = pEnumFeat.Next
 
   While Not pFeature Is Nothing
     If pFeature.Shape.GeometryType = esriGeometryPolygon Then
       Set pCurve = pFeature.Shape
       pCurve.ReverseOrientation
     End If
     Set pFeature = pEnumFeat.Next
   Wend
 
 End Sub
  
 

[C#]
public void ReverseOrientation()
{
  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;
        curve.ReverseOrientation();
    }
    
    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.