smithmc

Move Points to Closest Line with Same Line Number

Discussion created by smithmc on Aug 1, 2011
Latest reply on Aug 2, 2011 by jskinner-esristaff
I am trying to move some point that I have that are not snaped to the edge of the line.  I want to make sure they are snapped to the right line given some are very close to an intersection. 

I keep getting the error:

Runtime error <class 'arcgisscripting.ExecuteError'>: ERROR 999999: Error executing function. Cannot acquire a lock. Cannot acquire a lock. [The table Points is being written by another process.] Failed to execute (Snap).

As you can see I have tried updatecursors, seachcursors and even just a plain old SelectLayerByAttribute_management.  I am stuck!!!

rows = arcpy.UpdateCursor("Points")
#rows = arcpy.SearchCursor("Points")
#rows = arcpy.SelectLayerByAttribute_management("Points","SUBSET_SELECTION","OBJECTID > 0")
mxd = arcpy.mapping.MapDocument("CURRENT")
print mxd.filePath
for row in rows:
    LINENO=row.getValue("Line_ID")
    print "LINENO " + LINENO
    for lyr in arcpy.mapping.ListLayers(mxd):
        #print "lyr.name " + lyr.name
        lyrname = lyr.name
        #for what ever reason, you can not use an = in the next statement
        if lyr.name in ["AllLines"]:
           print "LINENUMBER = '" + LINENO + "'"
           lyr.definitionQuery = "LINENUMBER = '" + LINENO + "'"
           snapEnv = [AllLines, "EDGE", "2 Meters"]
           arcpy.Snap_edit("Points", [snapEnv])

Outcomes