As an example snippet how this could be done in Python:
def main():
import arcpy
fc_poly = r'C:\GeoNet\SelectPolygonByLine\data.gdb\polygons'
fc_line = r'C:\GeoNet\SelectPolygonByLine\data.gdb\line'
polyline = arcpy.da.SearchCursor(fc_line, ('SHAPE@')).next()[0]
fid_set = []
with arcpy.da.SearchCursor(fc_poly, ('SHAPE@', 'OID@')) as curs:
for row in curs:
polygon = row[0]
oid = row[1]
outline = polygon.boundary
result = polygon.intersect(polyline, 1)
if len(result) == 2:
fid_set.append(oid)
fld_oid = arcpy.Describe(fc_poly).OIDFieldname
where = '{0} IN ({1})'.format(arcpy.AddFieldDelimiters(fc_poly, fld_oid), ', '.join(str(a) for a in fid_set))
print where
if __name__ == '__main__':
main()
When using this situation (label of polygon is OBJECTID):
This will yield a where like:
OBJECTID IN (1, 2)
When I apply this to the polygon layer, you get this result:
But all depends on the precision of the data...