AnsweredAssumed Answered

Help with Snap_edit error in stand alone script

Question asked by cmwrenn3 on Apr 28, 2017
Latest reply on Apr 28, 2017 by cmwrenn3

Hello, all.

I am writing a script that will selectively snap address points to a road centerline.  This will ultimately be used to determine and report the closest hydrant to an address.


I am able to search through and select the addresses and the appropriate road segment, however I get an error (Error 000800: Not a member of END | VERTEX | EDGE) when I include the Snap_edit function.  It works from within ArcMap using a mdx, but not in a stand-alone script.  Any help is greatly appreciated.


Thanks in advance,



import arcpy
from arcpy import da

def even_addr(arow, crow):
    if int(arow[0]) in range(int(crow[2]), int(crow[3])):
        snapexpr = """{0} = {1}""".format(arcpy.AddFieldDelimiters('ADDR_Layer','OBJECTID'), arow[2])
        print('Even', snapexpr)  ## Flow trace
        arcpy.SelectLayerByAttribute_management(snap, 'NEW_SELECTION', snapexpr)
        arcpy.Snap_edit(snap, snapenv)

def odd_addr(arow, crow):
    if int(arow[0]) in range(int(crow[0]), int(crow[1])):
        snapexpr = """{0} = {1}""".format(arcpy.AddFieldDelimiters('ADDR_Layer','OBJECTID'),arow[2])
        print('Odd', snapexpr)  ## Flow trace
        arcpy.SelectLayerByAttribute_management(snap, 'NEW_SELECTION', snapexpr)
        arcpy.Snap_edit(snap, snapenv )

addr = r'Z:\Data\Projects\FIRE\Preplan\Closest_Hydrant.gdb\ADDRPTS_812'

cline = r'Z:\Data\Projects\FIRE\Preplan\Closest_Hydrant.gdb\WORK_RDCENTERLINES'
cflds = ['LLEFT', 'HLEFT', 'LRGT', 'HRGT','FULLNAME']
cexpr = 'FULLNAME > \' \''

snap = r'\ADDR_Layer'
snapenv = [cline, 'EDGE', '500 Feet']

arcpy.MakeFeatureLayer_management(addr, snap, workspace = None)
print('Feature Layer created')  ## Flow trace

with da.SearchCursor(addr, aflds, where_clause = aexpr, sql_clause = (None,'ORDER BY COMPLETE_STREET_NAME, COMPLETE_ADDRESS_NUMBER')) as acursor:
    for arow in acursor:

        with da.SearchCursor(cline, cflds, where_clause = cexpr ,sql_clause = (None,'ORDER BY FULLNAME, LLEFT')) as ccursor:
            for crow in ccursor:

                if '/' in arow[0]:
                    print('Fractional address: {0}'.format(arow[0]))  ## Flow trace
                if (arow[1]) == crow[4]:

                    if int(arow[0]) % 2 > 0:
                        odd_addr(arow, crow)
                        if int(arow[0]) % 2 == 0:
                            even_addr(arow, crow)
                            print('Error?  {0} : {1}'.format(arow, crow))  ## Flow trace

    print("Processed address")  ## Flow trace

print('Completed')  ## Flow trace

#  arow[0] - Address Number
#  arow[1] - Street Name
#  arow[2] - ObjectID

#  crow[0] - Lower Left Address Number
#  crow[1] - Higher Left Address Number
#  crow[2] - Lower Right Address Number
#  crow[3] - Higher Right Address Number
#  crow[4] - Street Name