This document is archived and information here might be outdated. Recommended version. |
The edit sketch direction of all of the selected polyline features is changed or flipped.
///<summary>The edit sketch direction of all of the selected polyline features is changed or flipped.</summary> /// ///<param name="application">An IApplication interface.</param> ///<param name="editor">An IEditor interface.</param> /// ///<remarks>Already must have a reference to IApplication and get the editor and start an edit session in the edit session you must have an edit selection, the code checks to make sure it is a line feature class and makes sure that there is an edit selection.</remarks> public void FlipLineDirection(ESRI.ArcGIS.Framework.IApplication application, ESRI.ArcGIS.Editor.IEditor editor) { if(application == null || editor == null) { System.Windows.Forms.MessageBox.Show("Flip operation aborted"); return; } ESRI.ArcGIS.Editor.IEditLayers editLayers=editor as ESRI.ArcGIS.Editor.IEditLayers; // set up the progress bar and convert the number of selected features into an integer value. System.Int32 step=System.Convert.ToInt32(editor.SelectionCount / 100); ESRI.ArcGIS.esriSystem.IStatusBar statusBar=application.StatusBar; ESRI.ArcGIS.esriSystem.IStepProgressor stepProrogressor=statusBar.ProgressBar; stepProrogressor.MinRange=1; stepProrogressor.MaxRange=100; stepProrogressor.Message="Flipping features..."; stepProrogressor.Position=0; stepProrogressor.StepValue=1; stepProrogressor.Show(); try { // flip all the selected features in an edit operation editor.StartOperation(); ESRI.ArcGIS.Geodatabase.IEnumFeature enumFeature=editor.EditSelection; enumFeature.Reset(); for (System.Int32 featCount=0; featCount <= editor.SelectionCount - 1; featCount++) { ESRI.ArcGIS.Geodatabase.IFeature feature=enumFeature.Next(); if(!(feature is ESRI.ArcGIS.Geometry.ICurve)) { continue; } ESRI.ArcGIS.Geometry.ICurve curve=feature.Shape as ESRI.ArcGIS.Geometry.ICurve; curve.ReverseOrientation(); feature.Shape=curve; feature.Store(); if (featCount == step) { stepProrogressor.Step(); step=step + System.Convert.ToInt32(editor.SelectionCount / 100); } } editor.StopOperation("Flip"); stepProrogressor.Hide(); return; } catch(System.Exception e) { editor.AbortOperation(); System.Windows.Forms.MessageBox.Show("Flip operation aborted"); return; } }
'''<summary>The edit sketch direction of all of the selected polyline features is changed or flipped.</summary> ''' '''<param name="application">An IApplication interface.</param> '''<param name="editor">An IEditor interface.</param> ''' '''<remarks>Already must have a reference to IApplication and get the editor and start an edit session in the edit session you must have an edit selection, the code checks to make sure it is a line feature class and makes sure that there is an edit selection.</remarks> Public Sub FlipLineDirection(ByVal application As ESRI.ArcGIS.Framework.IApplication, ByVal editor As ESRI.ArcGIS.Editor.IEditor) If application Is Nothing OrElse editor Is Nothing Then System.Windows.Forms.MessageBox.Show("Flip operation aborted") Return End If Dim editLayers As ESRI.ArcGIS.Editor.IEditLayers=TryCast(editor, ESRI.ArcGIS.Editor.IEditLayers) ' set up the progress bar and convert the number of selected features into an integer value. Dim [step] As System.Int32=System.Convert.ToInt32(editor.SelectionCount / 100) Dim statusBar As ESRI.ArcGIS.esriSystem.IStatusBar=application.StatusBar Dim stepProgressor As ESRI.ArcGIS.esriSystem.IStepProgressor=statusBar.ProgressBar With stepProgressor .MinRange=1 .MaxRange=100 .Message="Flipping features..." .Position=0 .StepValue=1 .Show() End With Try ' flip all the selected features in an edit operation editor.StartOperation() Dim enumFeature As ESRI.ArcGIS.Geodatabase.IEnumFeature=editor.EditSelection enumFeature.Reset() Dim featCount As System.Int32=0 Do While featCount <= editor.SelectionCount - 1 Dim feature As ESRI.ArcGIS.Geodatabase.IFeature=enumFeature.Next If Not(TypeOf feature Is ESRI.ArcGIS.Geometry.ICurve) Then featCount += 1 Continue Do End If Dim curve As ESRI.ArcGIS.Geometry.ICurve=TryCast(feature.Shape, ESRI.ArcGIS.Geometry.ICurve) ' Dynamic Cast curve.ReverseOrientation() feature.Shape=curve feature.Store() If featCount=[step] Then stepProgressor.Step() [step]=[step] + System.Convert.ToInt32(editor.SelectionCount / 100) End If featCount += 1 Loop editor.StopOperation("Flip") stepProgressor.Hide() Return Catch e As System.Exception editor.AbortOperation() System.Windows.Forms.MessageBox.Show("Flip operation aborted") Return End Try End Sub