import arcpy import pythonaddins global coords, mxd, df, ids coords = [] ids = [] mxdPath = r'E:\gis\Atlas\Atlas.mxd' mxd = arcpy.mapping.MapDocument(mxdPath) class DrawPolygon(object): """Implementation for searchAtlas_addin.drawPolygonTl (Tool)""" def __init__(self): self.enabled = True self.shape = "Line" def onLine(self, line_geometry): array = arcpy.Array() part = line_geometry.getPart(0) for pt in part: array.add(pt) polygon = arcpy.Polygon(array) getBlockIDs(polygon) def getBlockIDs(inPolygon): print 'getting block ids' fc = r'E:\gis\Atlas\default.gdb\blocks' arcpy.MakeFeatureLayer_management(fc, 'blocksLyr') arcpy.MakeFeatureLayer_management(inPolygon, 'aoiLyr') arcpy.SelectLayerByLocation_management('blocksLyr', 'INTERSECT', 'aoiLyr') with arcpy.da.SearchCursor(fc, 'BlockNumber') as c: for r in c: ids.append(r[0]) print ids
Solved! Go to Solution.
with arcpy.da.SearchCursor(fc, 'BlockNumber') as c: for r in c: ids.append(r[0])
with arcpy.da.SearchCursor('blocksLyr', 'BlockNumber') as c: for r in c: ids.append(r[0])
block_lyr = arcpy.MakeFeatureLayer_management(fc, 'blocksLyr').getOutput(0) .... .... with arcpy.da.SearchCursor(block_lyr, 'BlockNumber') as c: for r in c: ids.append(r[0])
with arcpy.da.SearchCursor(fc, 'BlockNumber') as c: for r in c: ids.append(r[0])
with arcpy.da.SearchCursor('blocksLyr', 'BlockNumber') as c: for r in c: ids.append(r[0])
block_lyr = arcpy.MakeFeatureLayer_management(fc, 'blocksLyr').getOutput(0) .... .... with arcpy.da.SearchCursor(block_lyr, 'BlockNumber') as c: for r in c: ids.append(r[0])
: \ Brain stall! Thanks Caleb!