AnsweredAssumed Answered

Flip subset of lines using arcpy.FlipLine_edit in a Python script

Question asked by dmccormick on Mar 12, 2014
Latest reply on Mar 12, 2014 by dmccormick
In a Python script I can't seem to get FlipLine_edit to work on a selected set of lines contained within a shapefile. Unfortunately, all of the lines are getting flipped instead of just those that are selected.

Steps I am using (note code snippet pasted below, full script attached):

  1. Create a layer using MakeFeatureLayer

  2. Count all lines using GetCount (report result with print statement)

  3. Select a subset of lines using SelectLayerByAttribute

  4. Count selected lines using GetCount (report result with print statement)

  5. Attempt to change direction of selected lines using FlipLine_edit

arcpy.MakeFeatureLayer_management(shpLine, "lyrLines") strCountAll = str(arcpy.GetCount_management("lyrLines")) print "Count of all features is " + strCountAll arcpy.SelectLayerByAttribute_management("lyrLines", "NEW_SELECTION", '"Flip_yn" = \'yes\'') strCountSelected = str(arcpy.GetCount_management("lyrLines")) print "Count of selected features is " + strCountSelected arcpy.FlipLine_edit(shpLine) arcpy.SelectLayerByAttribute_management("lyrLines", "CLEAR_SELECTION") 

In ArcMap, when using the Flip Line tool contained within Editing Tools:

  • No lines selected: all lines will be flipped

  • One line selected: the selected line will be flipped

FYI: I have 64-bit Windows 7 with ArcGIS 10.1 (ArcInfo license) and both Python 2.7.2 and Pythonwin (both 2.7.2)

I also tried using FlipLine using arcpy.da.UpdateCursor, but individual lines were not being flipped this way either.

Thanks in advance for any input!