HOW TO

Create extent indicators for multiple layouts using Python in ArcGIS Pro

First Published: July 8, 2026
Last Published: July 8, 2026

Summary

In ArcGIS Pro, an extent indicator can be manually added to a layout that contains at least two 2D map frames. To streamline the process for multiple layouts, ArcPy can be used to programmatically add extent indicators to each map frame by accessing and modifying the Cartographic Information Model (CIM) through Python CIM access.

Procedure

  1. Open the project containing the layouts with the required map frames in ArcGIS Pro.
  2. On the View ribbon tab, in the Windows group, click Python Window.
  3. In the Python window, copy and paste the code to create an extent indicator.
Note:
Avoid pressing Enter between lines, as this creates indentation errors. The entire script must be run at once.
  1. Import the ArcPy library.
import arcpy
  1. Iterate through all layouts to retrieve the main map frame. Replace <Main MF> with the name of the main map frames. Ensure the names of the main map frames are identical across all layouts.
for lyt in p.listLayouts():
    mf_list = lyt.listElements('MapFrame_Element', '<Main MF>')
    if not mf_list:
        continue
    mf = mf_list[0]
  1. Retrieve the CIM definition of the layout.
    lyt_cim = lyt.getDefinition('V3')
  1. Create the symbol design for the extent indicator.
    stroke_color = arcpy.cim.CreateCIMObjectFromClassName('CIMRGBColor', 'V3')
    stroke_color.values = [255, 0, 0, 100]

    fill_color = arcpy.cim.CreateCIMObjectFromClassName('CIMRGBColor', 'V3')
    fill_color.values = [0, 0, 0, 0]

    stroke = arcpy.cim.CreateCIMObjectFromClassName('CIMSolidStroke', 'V3')
    stroke.width = 1
    stroke.color = stroke_color

    fill = arcpy.cim.CreateCIMObjectFromClassName('CIMSolidFill', 'V3')
    fill.color = fill_color

    symbol = arcpy.cim.CreateCIMObjectFromClassName('CIMPolygonSymbol', 'V3')
    symbol.symbolLayers = [stroke, fill]

    symbol_ref = arcpy.cim.CreateCIMObjectFromClassName('CIMSymbolReference', 'V3')
    symbol_ref.symbol = symbol
  1. Create the extent indicator.
    ei_cim = arcpy.cim.CreateCIMObjectFromClassName('CIMExtentIndicator', 'V3')
    ei_cim.sourceMapFrame = mf.name
    ei_cim.extentIndicatorType = "Frame"
    ei_cim.isVisible = True
    ei_cim.name = "extent_indicator"
    ei_cim.symbol = symbol_ref
  1. Insert the extent indicator into the locator map frame. Replace <Locator MF> with the name of the locator or inset map. Ensure the names of the map frames are identical across all layouts.
    for elm in lyt_cim.elements:
        if elm.name == '<Locator MF>':
            if not elm.extentIndicators:
                elm.extentIndicators = []
            elm.extentIndicators.insert(0, ei_cim)
  1. Apply the updated CIM definition to the layout.
    lyt.setDefinition(lyt_cim)

The code below shows the full sample script.

import arcpy
p = arcpy.mp.ArcGISProject('current')
  
for lyt in p.listLayouts():
    mf_list = lyt.listElements('MapFrame_Element', '<Main MF>')
    if not mf_list:
        continue
    mf = mf_list[0]

    lyt_cim = lyt.getDefinition('V3')

    stroke_color = arcpy.cim.CreateCIMObjectFromClassName('CIMRGBColor', 'V3')
    stroke_color.values = [255, 0, 0, 100]
    fill_color = arcpy.cim.CreateCIMObjectFromClassName('CIMRGBColor', 'V3')
    fill_color.values = [0, 0, 0, 0]
    stroke = arcpy.cim.CreateCIMObjectFromClassName('CIMSolidStroke', 'V3')
    stroke.width = 1
    stroke.color = stroke_color
    fill = arcpy.cim.CreateCIMObjectFromClassName('CIMSolidFill', 'V3')
    fill.color = fill_color
    symbol = arcpy.cim.CreateCIMObjectFromClassName('CIMPolygonSymbol', 'V3')
    symbol.symbolLayers = [stroke, fill]
    symbol_ref = arcpy.cim.CreateCIMObjectFromClassName('CIMSymbolReference', 'V3')
    symbol_ref.symbol = symbol

    ei_cim = arcpy.cim.CreateCIMObjectFromClassName('CIMExtentIndicator', 'V3')
    ei_cim.sourceMapFrame = mf.name
    ei_cim.extentIndicatorType = "Frame"
    ei_cim.isVisible = True
    ei_cim.name = "extent_indicator"
    ei_cim.symbol = symbol_ref

    for elm in lyt_cim.elements:
        if elm.name == '<Locator MF>':
            if not elm.extentIndicators:
                elm.extentIndicators = []
            elm.extentIndicators.insert(0, ei_cim)

    lyt.setDefinition(lyt_cim)
  1. Press Enter twice to run the script.

The extent indicator is displayed in the map frame on the layout, as shown below.

The extent indicator

Article ID: 000042116

Software:
  • ArcGIS Pro

Get support with AI

Resolve your issue quickly with the Esri Support AI Chatbot.

Start chatting now

Related Information

Discover more on this topic

Get help from ArcGIS experts

Contact technical support

Start chatting now

Go to download options