smithmc

snap_edit and near_analysis do not seem to recognize the definition query

Discussion created by smithmc on Jul 16, 2012
Latest reply on Jul 16, 2012 by jskinner-esristaff
I am trying to move all my points to the appropriate lines if they have the same line number.  I am setting the definition query but when the code runs it does not recognize the definition queary and moves the point to any line that is closest.  The same thing is happening with the near analysis.  Any thoughts?

for count in range(0,x):
     for lyr in arcpy.mapping.ListLayers(mxd):
        lyrname = lyr.name
        if lyr.name in ["Lines"]:
           lyr.definitionQuery = "line_id = '" + LineIDList[count] + "'"
        if lyr.name in ["Points"]:
           lyr.definitionQuery = "line_id =  '" + LineIDList[count] + "'"
    try:
        arcpy.Snap_edit("Points", ["Lines", "EDGE", "1000"])
        arcpy.Near_analysis("Points", AllLines2)
        print "Processed " + str(count) + " of " + str(x) + ' line ' + LineIDList[count]
    except:
print arcpy.GetMessages(2)

Outcomes