AnsweredAssumed Answered

Cursor and Select by Location

Question asked by msk05004 on Feb 6, 2016
Latest reply on Feb 6, 2016 by msk05004



I have a cursor cycling through several polygon features.  Would like to pass the current cursor entry to the Select by Location tool, to select a series of lines contained by the polygons.  I am getting an error stating the Select by Location tool is not working.


Is my syntax correct?  In the for loop, I defined for "Cup_row in C_update"; do I just pass "Cup_row" as the input to the "SelectLayerByLocation_management" tool


The "A2" exception is displaying "Object: Error in executing tool"


for Cup_row in C_update:

    Cup_totalest = Cup_row[0] 
    Cup_totalmoe = Cup_row[1]
    Cup_pairid   = Cup_row[2]
    Cup_subpairs = Cup_row[3]
    Cup_OX       = Cup_row[4]
    Cup_OY       = Cup_row[5]
    Cup_DX       = Cup_row[6]
    Cup_DY       = Cup_row[7]

    #initial values
    Cup_totalest = 0.0
    Cup_totalmoe = 0.0
    Cup_pairid = ""
    C_pairlist = []        
    if(p_er):print "A1"
    #---Select Subpairs containted by corridor---##
        arcpy.SelectLayerByLocation_management(Cup_row, "COMPLETELY_CONTAINS", P_paths, "", "NEW_SELECTION")
    except Exception as A2:
        print "A2 "+ str(A2)