The script below will create a new shapefile with a feature representing the extent of each data frame in a map document. The data frame name is saved in a field called DFName
. Once you've run this you can add it to your main data frame as a normal layer and exclude it as you would any other (the "Exclude layers..." button).
You'll still need to leave the existing extent indicators on if you want to use leader lines between the dataframes and their extent indicators.
import arcpy
import os
folder = r'C:\Data' # adjust as required
mxd = arcpy.mapping.MapDocument('CURRENT')
dfs = arcpy.mapping.ListDataFrames(mxd)
fc = arcpy.CreateFeatureclass_management(folder, 'extent.shp', "POLYGON", None, "DISABLED", "DISABLED", None)
arcpy.AddField_management(fc, 'DFName', 'TEXT', None, None, 250, "", "NULLABLE", "NON_REQUIRED")
cur = arcpy.InsertCursor(os.path.join(folder, 'extent.shp'))
for df in dfs:
extent = df.extent
array = arcpy.Array()
array.add(extent.lowerLeft)
array.add(extent.lowerRight)
array.add(extent.upperRight)
array.add(extent.upperLeft)
array.add(extent.lowerLeft)
polygon = arcpy.Polygon(array)
feat = cur.newRow()
feat.shape = polygon
feat.DFName = df.name
cur.insertRow(feat)
array.removeAll()
del(cur)