Solved! Go to Solution.
import arcpy, os layerName = arcpy.GetParameterAsText(0) # Set script parameter as type Feature Layer mxd = arcpy.mapping.MapDocument("CURRENT") # assuming one data frame layer = arcpy.mapping.ListLayers(mxd, os.path.basename(layerName))[0] # basename strips off a ToC group(s) edit = arcpy.da.Editor(layer.workspacePath) # Need to make sure workspacePath is being populated edit.startEditing(False, True) edit.startOperation() # [...] cursor operations, data writing, updateRow calls here edit.stopOperation() edit.stopEditing(True)
import arcpy, os layerName = arcpy.GetParameterAsText(0) # Set script parameter as type Feature Layer mxd = arcpy.mapping.MapDocument("CURRENT") # assuming one data frame layer = arcpy.mapping.ListLayers(mxd, os.path.basename(layerName))[0] # basename strips off a ToC group(s) edit = arcpy.da.Editor(layer.workspacePath) # Need to make sure workspacePath is being populated edit.startEditing(False, True) edit.startOperation() # [...] cursor operations, data writing, updateRow calls here edit.stopOperation() edit.stopEditing(True)
See this Esri page for details: Editor (arcpy.da) (Note: as of Apr 9, 2013 this page has a typo in example 2 at the bottom: the startEditing and startOperation call order is reversed, it should be startEditing first and then startOperation).