Select or export rows one by one

Discussion created by sailitang on Apr 19, 2012
Latest reply on Apr 24, 2012 by m.gasior

  Please see the following code. I use rows to access attributes table of selfeat. The code will do 'intersect' between each feature of selfeat and all features of curfeat. If two features in curfeat are selected, the feature in selfeat will be selected or exported to the other feature class or layer or... And then, continue to next row's feature till bottom. Anyone knows how to do the selecting or exporting like this. Thank you.

   rows = gp.SearchCursor(selfeat, "", "", "OBJECTID", "OBJECTID A")
   for row in rows:
       gp.SelectLayerByAttribute_management(selfeat, "NEW_SELECTION", "OBJECTID = row.OBJECTID")
       gp.SelectLayerByLocation_management(curfeat, 'INTERSECT', selfeat)
       matchcount = int(gp.GetCount_management(curfeat).getOutput(0))
       if matchcount == 2: