Layout

Summary

The Layout object references a single-page layout in an ArcGIS Pro project (.aprx). It provides access to common properties like page size and a number of different export methods.

Discussion

An ArcGIS Pro project can contain multiple page layouts. Layouts are accessed using the listLayouts method on the ArcGISProject object and it returns a Python list of Layout objects. It is important to uniquely name each layout so a specific page layout can be easily referenced by its name.

The listElements method provides access to all the elements on the page layout: GraphicElement, LegendElement, MapFrameElement, MapSurroundElement, PictureElement, and TextElement.

The Layout object is where you'll find access to a number of exportTo methods. Use the Layout export methods if you want to export the entire page layout. There is also a similar set of export methods available on the MapFrame class, if you only want to export the contents of a single map frame.

A layout can contain a single MapSeries. If the mapSeries property returns None, then a map series has not been created in the layout. You should also check to see if the map series is enabled before attempting to manipulate its properties.

Properties

PropertyExplanationData Type
mapSeries
(Read Only)

Returns a MapSeries object if a spatial map series is enabled. It returns a NoneType if a map series does not exist or it is a bookmark map series.

MapSeries
metadata
(Read and Write)

Get or set the layout's Metadata class information. Note, setting metadata is dependent on the isReadOnly property value.

Metadata
name
(Read and Write)

The layout's name. It is important that all layouts have a unique name so they can be easily referenced by name.

String
pageHeight
(Read and Write)

A layout's page height based on the current pageUnits.

Double
pageUnits
(Read and Write)

A layout's page units. Below is a list of valid strings when setting the page units.

  • CENTIMETERCentimeter
  • INCHInch
  • MILLIMETERMillimeter
  • POINTPoint
String
pageWidth
(Read and Write)

A layout's page width based on the current pageUnits.

Double

Method Overview

MethodExplanation
exportToAIX (out_aix, {resolution}, {image_quality}, {compress_vector_graphics}, {image_compression}, {jpeg_compression_quality}, {embed_fonts}, {embed_color_profile}, {clip_to_elements}, {keep_layout_background})

Exports a page layout to Adobe Creative Cloud (AIX) format.

exportToBMP (out_bmp, {resolution}, {bmp_color_mode}, {bmp_image_compression}, {embed_color_profile}, {clip_to_elements})

Exports the page layout to the Microsoft Windows Bitmap format (BMP).

exportToEMF (out_emf, {resolution}, {image_quality}, {output_as_image}, {clip_to_elements})

Exports the page layout to the Enhanced Metafile (EMF) format.

exportToEPS (out_eps, {resolution}, {image_compression}, {image_quality}, {embed_fonts}, {output_as_image}, {clip_to_elements})

Exports a page layout to an Encapsulated PostScript (EPS) format file.

exportToGIF (out_gif, {resolution}, {gif_color_mode}, {clip_to_elements})

Exports a page layout to Graphic Interchange Format (GIF).

exportToJPEG (out_jpg, {resolution}, {jpeg_color_mode}, {jpeg_quality}, {embed_color_profile}, {clip_to_elements})

Exports a page layout to a Joint Photographic Experts Group (JPEG) format file.

exportToPAGX (out_pagx)

Exports a layout to a page file.

exportToPDF (out_pdf, {resolution}, {image_quality}, {compress_vector_graphics}, {image_compression}, {embed_fonts}, {layers_attributes}, {georef_info}, {jpeg_compression_quality}, {clip_to_elements}, {output_as_image}, {embed_color_profile})

Exports a page layout to Portable Document Format (PDF).

exportToPNG (out_png, {resolution}, {color_mode}, {transparent_background}, {embed_color_profile}, {clip_to_elements})

Exports a page layout to a Portable Network Graphics (PNG) format file.

exportToSVG (out_svg, {resolution}, {compress_to_svgz}, {image_quality}, {embed_fonts}, {output_as_image}, {clip_to_elements})

Exports a page layout to the Scalable Vector Graphics format (SVG).

exportToTGA (out_tga, {resolution}, {color_mode}, {transparent_background}, {clip_to_elements})

Exports the page layout to the Truevision Graphics Adapter format (TGA).

exportToTIFF (out_tif, {resolution}, {color_mode}, {tiff_compression}, {jpeg_compression_quality}, {transparent_background}, {embed_color_profile}, {clip_to_elements}, {world_file}, {geoTIFF_tags}, {georef_mapframe})

Exports the page layout to a Tagged Image File Format (TIFF) file.

getDefinition (cim_version)

Gets a layout's CIM definition.

listElements ({element_type}, {wildcard})

Returns a Python list of page layout elements that exist on a Layout object.

setDefinition (definition_object)

Sets a layout's CIM definition.

Methods

exportToAIX (out_aix, {resolution}, {image_quality}, {compress_vector_graphics}, {image_compression}, {jpeg_compression_quality}, {embed_fonts}, {embed_color_profile}, {clip_to_elements}, {keep_layout_background})
ParameterExplanationData Type
out_aix

A string that represents the path and file name for the output export file.

String
resolution

A number that defines the resolution of the export file in dots per inch (dpi).

(The default value is 300)

Integer
image_quality

A string that specifies output image quality, the draw resolution of map layers that draw as rasters.

  • BESTAn output image quality resample ratio of 1
  • BETTERAn output image quality resample ratio of 2
  • NORMALAn output image quality resample ratio of 3
  • FASTERAn output image quality resample ratio of 4
  • FASTESTAn output image quality resample ratio of 5

(The default value is BEST)

String
compress_vector_graphics

A Boolean that controls compression of vector and text portions of the output file. Image compression is defined separately.

(The default value is True)

Boolean
image_compression

A string that specifies the compression scheme used to compress image or raster data in the output file.

  • ADAPTIVEAutomatically selects the best compression type for each image on the page. JPEG will be used for large images with many unique colors. DEFLATE will be used for all other images.
  • DEFLATEA lossless data compression.
  • JPEGA lossy data compression.
  • LZWLempel-Ziv-Welch, a lossless data compression.
  • NONECompression is not applied.
  • RLERun-length encoded compression.

(The default value is ADAPTIVE)

String
jpeg_compression_quality

A number that controls compression quality value when image_compression is set to ADAPTIVE or JPEG. The valid range is 1 through 100. A jpeg_compression_quality of 100 provides the best-quality images but creates large export files. The recommended range is between 70 and 90.

(The default value is 80)

Integer
embed_fonts

A Boolean that controls the embedding of fonts in the export file. Font embedding allows text and character markers to be displayed correctly when the document is viewed on a computer that does not have the necessary fonts installed.

(The default value is True)

Boolean
embed_color_profile

If set to True, color profile information is embedded in the image's metadata.

(The default value is True)

Boolean
clip_to_elements

If set to True, the layout is clipped to the smallest bounding box that includes all layout elements.

(The default value is False)

Boolean
keep_layout_background

If set to True, the layout's white background will be kept.

(The default value is True)

Boolean

AIX is an Adobe Illustrator Exchange file exported from ArcGIS to be used with the ArcGIS Maps for Adobe Creative Cloud plug-in. When used with the plug-in, vector and raster map content is converted into editable, layered artwork for an improved editing experience in Adobe Illustrator. Once opened in Illustrator, it can be used for high-end graphic design or map finishing workflows and migrated across the other Adobe Creative Cloud applications.

exportToBMP (out_bmp, {resolution}, {bmp_color_mode}, {bmp_image_compression}, {embed_color_profile}, {clip_to_elements})
ParameterExplanationData Type
out_bmp

A string that represents the path and file name for the output export file.

String
resolution

A number that defines the resolution of the export file in dots per inch (dpi).

(The default value is 96)

Integer
bmp_color_mode

This value specifies the number of bits used to describe color.

  • 8-BIT_ADAPTIVE_PALETTE8-bit adaptive palette
  • 8-BIT_GRAYSCALE8-bit grayscale
  • 24-BIT_TRUE_COLOR24-bit true color

(The default value is 24-BIT_TRUE_COLOR)

String
bmp_image_compression

A string that specifies the compression scheme used to compress image or raster data in the output file. This option only applies to 8-bit bmp_color_mode options.

  • NONECompression is not applied.
  • RLERun-length encoded compression.

(The default value is NONE)

String
embed_color_profile

If set to True, color profile information is embedded in the image's metadata.

(The default value is True)

Boolean
clip_to_elements

If set to True, the layout is clipped to the smallest bounding box that includes all layout elements.

(The default value is False)

Boolean

BMP files are native Windows raster images. BMP files can store pixel data at several bit depths. BMP images are typically much larger than formats such as JPEG or PNG.

exportToEMF (out_emf, {resolution}, {image_quality}, {output_as_image}, {clip_to_elements})
ParameterExplanationData Type
out_emf

A string that represents the system path and file name for the output export file.

String
resolution

A number that defines the resolution of the export file in dots per inch (dpi).

(The default value is 96)

Integer
image_quality

A string that specifies output image quality, the draw resolution of map layers that draw as rasters.

  • BESTAn output image quality resample ratio of 1
  • BETTERAn output image quality resample ratio of 2
  • NORMALAn output image quality resample ratio of 3
  • FASTERAn output image quality resample ratio of 4
  • FASTESTAn output image quality resample ratio of 5

(The default value is BEST)

String
output_as_image

If set to True, vector content can be saved as an image. Selecting this option for maps or layouts that contain vector layers with a high density of vertices can reduce the output file size. When exporting to PDF and this option is set to True, you cannot view PDF layers in the output.

(The default value is False)

Boolean
clip_to_elements

If set to True, the layout is clipped to the smallest bounding box that includes all layout elements.

(The default value is False)

Boolean

EMF files are native Windows graphics files that can contain a mixture of vector and raster data. They are useful for embedding in Windows documents because the vector portions of the EMF can be resized without loss of quality. However, since EMF does not support font embedding and is exclusively a Windows format, it is not commonly used as an interchange format between users.

exportToEPS (out_eps, {resolution}, {image_compression}, {image_quality}, {embed_fonts}, {output_as_image}, {clip_to_elements})
ParameterExplanationData Type
out_eps

A string that represents the system path and file name for the output export file.

String
resolution

A number that defines the resolution of the export file in dots per inch (dpi).

(The default value is 96)

Integer
image_compression

A string that specifies the compression scheme used to compress image or raster data in the output file.

  • DEFLATEA lossless data compression.
  • LZWLempel-Ziv-Welch, a lossless data compression.
  • NONECompression is not applied.
  • RLERun-length encoded compression.

(The default value is DEFLATE)

String
image_quality

A string that specifies output image quality, the draw resolution of map layers that draw as rasters.

  • BESTAn output image quality resample ratio of 1.
  • BETTERAn output image quality resample ratio of 2.
  • NORMALAn output image quality resample ratio of 3.
  • FASTERAn output image quality resample ratio of 4.
  • FASTESTAn output image quality resample ratio of 5.

(The default value is BEST)

String
embed_fonts

A Boolean that controls the embedding of fonts in the export file. Font embedding allows text and character markers to be displayed correctly when the document is viewed on a computer that does not have the necessary fonts installed.

(The default value is True)

Boolean
output_as_image

If set to True, vector content can be saved as an image. Selecting this option for maps or layouts that contain vector layers with a high density of vertices can reduce the output file size. When exporting to PDF and this option is set to True, you cannot view PDF layers in the output.

(The default value is False)

Boolean
clip_to_elements

If set to True, the layout is clipped to the smallest bounding box that includes all layout elements.

(The default value is False)

Boolean

EPS files use the PostScript page description language to describe vector and raster objects. PostScript is the publishing industry standard for high-end graphics files, cartography, and printing. EPS files can be edited in many drawing applications or placed as a graphic in most page layout applications. EPS files support embedding of fonts so users who do not have Esri fonts installed can still view the proper symbology.

exportToGIF (out_gif, {resolution}, {gif_color_mode}, {clip_to_elements})
ParameterExplanationData Type
out_gif

A string that represents the system path and file name for the output export file.

String
resolution

A number that defines the resolution of the export file in dots per inch (dpi).

(The default value is 96)

Integer
gif_color_mode

This value specifies the number of bits used to describe color.

  • 8-BIT_PALETTE8-bit adaptive palette
  • 8-BIT_GRAYSCALE8-bit grayscale

(The default value is 8-BIT_PALETTE)

String
clip_to_elements

If set to True, the layout is clipped to the smallest bounding box that includes all layout elements.

(The default value is False)

Boolean

GIF files are a legacy raster format for use on the web. GIF files cannot contain more than 256 colors (8 bits per pixel), which along with optional lossless compression, makes them smaller than other file formats.

exportToJPEG (out_jpg, {resolution}, {jpeg_color_mode}, {jpeg_quality}, {embed_color_profile}, {clip_to_elements})
ParameterExplanationData Type
out_jpg

A string that represents the path and file name of the output export file.

String
resolution

A number that defines the resolution of the export file in dots per inch (dpi).

(The default value is 96)

Integer
jpeg_color_mode

This value specifies the number of bits used to describe color.

  • 8-BIT_GRAYSCALE8-bit grayscale
  • 24-BIT_TRUE_COLOR24-bit true color

(The default value is 24-BIT_TRUE_COLOR)

String
jpeg_quality

This value (0–100) controls the amount of compression applied to the output image. With a JPEG image, quality is adversely affected the more compression is applied. A higher quality (highest = 100) setting will produce sharper images and larger file sizes. A lower quality setting will produce more image artifacts and smaller files.

(The default value is 80)

Integer
embed_color_profile

If set to True, color profile information is embedded in the image's metadata.

(The default value is True)

Boolean
clip_to_elements

If set to True, the layout is clipped to the smallest bounding box that includes all layout elements.

(The default value is False)

Boolean

JPEG files are compressed image files. They support 24-bit color and are a popular choice for use on the web because a JPEG file size is often substantially smaller than many other image formats. However, the JPEG compression algorithm is lossy and is not recommended for many map images, as line drawings, and text or icon graphics, become blurred by compression artifacts. Therefore, PNG is usually a superior format for map images.

exportToPAGX (out_pagx)
ParameterExplanationData Type
out_pagx

A string used to save a layout to a page file (.pagx).

String

This method is useful if you want to save a layout to a page file that can be imported later into a project using the ArcGISProject importDocument method.

exportToPDF (out_pdf, {resolution}, {image_quality}, {compress_vector_graphics}, {image_compression}, {embed_fonts}, {layers_attributes}, {georef_info}, {jpeg_compression_quality}, {clip_to_elements}, {output_as_image}, {embed_color_profile})
ParameterExplanationData Type
out_pdf

A string that represents the path and file name for the output export file.

String
resolution

A number that defines the resolution of the export file in dots per inch (dpi).

(The default value is 300)

Integer
image_quality

A string that specifies output image quality, the draw resolution of map layers that draw as rasters.

  • BESTAn output image quality resample ratio of 1.
  • BETTERAn output image quality resample ratio of 2.
  • NORMALAn output image quality resample ratio of 3.
  • FASTERAn output image quality resample ratio of 4.
  • FASTESTAn output image quality resample ratio of 5.

(The default value is BEST)

String
compress_vector_graphics

A Boolean that controls compression of vector and text portions of the output file. Image compression is defined separately.

(The default value is True)

Boolean
image_compression

A string that specifies the compression scheme used to compress image or raster data in the output file.

  • ADAPTIVEAutomatically selects the best compression type for each image on the page. JPEG will be used for large images with many unique colors. DEFLATE will be used for all other images.
  • DEFLATEA lossless data compression.
  • JPEGA lossy data compression.
  • LZWLempel-Ziv-Welch, a lossless data compression.
  • NONECompression is not applied.
  • RLERun-length encoded compression.

(The default value is ADAPTIVE)

String
embed_fonts

A Boolean that controls the embedding of fonts in the export file. Font embedding allows text and character markers to be displayed correctly when the document is viewed on a computer that does not have the necessary fonts installed.

(The default value is True)

Boolean
layers_attributes

A string that specifies whether the PDF layer and PDF object data (attributes) will be included in the export file.

  • LAYERS_ONLYExport PDF layers only
  • LAYERS_AND_ATTRIBUTESExport PDF layers and feature attributes
  • NONENone

(The default value is LAYERS_ONLY)

String
georef_info

A Boolean that enables the export of coordinate system information for each data frame into the output PDF file.

(The default value is True)

Boolean
jpeg_compression_quality

A number that controls compression quality value when image_compression is set to ADAPTIVE or JPEG. The valid range is 1 through 100. A jpeg_compression_quality of 100 provides the best quality images but creates large export files. The recommended range is between 70 and 90.

(The default value is 80)

Integer
clip_to_elements

If set to True, the layout is clipped to the smallest bounding box that includes all layout elements.

(The default value is False)

Boolean
output_as_image

If set to True, vector content can be saved as an image. Selecting this option for maps or layouts that contain vector layers with a high density of vertices can reduce the output file size. When exporting to PDF and this option is set to True, you cannot view PDF layers in the output.

(The default value is False)

Boolean
embed_color_profile

If set to True, color profile information is embedded in the image's metadata.

(The default value is True)

Boolean

PDF files are designed to be consistently viewable and printable across different platforms. They are commonly used for distributing documents on the web, and the format is now an official ISO standard for document interchange. PDF files are editable in many graphics applications and retain map georeference information, annotation, labeling, and feature attribute data. PDF exports support embedding of fonts and can display symbology correctly even if the user does not have Esri fonts installed.

Review the PDFDocument class to learn more about how to manage PDF files, such as appending, inserting, and setting properties.

exportToPNG (out_png, {resolution}, {color_mode}, {transparent_background}, {embed_color_profile}, {clip_to_elements})
ParameterExplanationData Type
out_png

A string that represents the path and file name of the output export file.

String
resolution

A number that defines the resolution of the export file in dots per inch (dpi).

(The default value is 96)

Integer
color_mode

This value specifies the number of bits used to describe color.

  • 8-BIT_ADAPTIVE_PALETTE8-bit adaptive palette
  • 8-BIT_GRAYSCALE8-bit grayscale
  • 24-BIT_TRUE_COLOR24-bit true color
  • 32-BIT_WITH_ALPHA32-bit with alpha

(The default value is 32-BIT_WITH_ALPHA)

String
transparent_background

If set to True, the white page background is set to transparent.

(The default value is False)

Boolean
embed_color_profile

If set to True, color profile information is embedded in the image's metadata.

(The default value is True)

Boolean
clip_to_elements

If set to True, the layout is clipped to the smallest bounding box that includes all layout elements.

(The default value is False)

Boolean

A PNG file is a versatile raster format file that can display in web browsers and be inserted into other documents. It supports high-bit-depth color and uses a lossless compression. For maps, PNG is often the best raster format, since the lossless compression keeps text and line work legible by preventing the compression artifacts that can occur in JPEG format. PNG files can also define a transparent color.

exportToSVG (out_svg, {resolution}, {compress_to_svgz}, {image_quality}, {embed_fonts}, {output_as_image}, {clip_to_elements})
ParameterExplanationData Type
out_svg

A string that represents the path and file name for the output export file.

String
resolution

A number that defines the resolution of the export file in dots per inch (dpi).

(The default value is 96)

Integer
compress_to_svgz

If set to True, the output is compressed.

(The default value is False)

Boolean
image_quality

A string that specifies output image quality, the draw resolution of map layers that draw as rasters.

  • BESTAn output image quality resample ratio of 1.
  • BETTERAn output image quality resample ratio of 2.
  • NORMALAn output image quality resample ratio of 3.
  • FASTERAn output image quality resample ratio of 4.
  • FASTESTAn output image quality resample ratio of 5.

(The default value is BEST)

String
embed_fonts

A Boolean that controls the embedding of fonts in the export file. Font embedding allows text and character markers to be displayed correctly when the document is viewed on a computer that does not have the necessary fonts installed.

(The default value is True)

Boolean
output_as_image

If set to True, vector content can be saved as an image. Selecting this option for maps or layouts that contain vector layers with a high density of vertices can reduce the output file size. When exporting to PDF and this option is set to True, you cannot view PDF layers in the output.

(The default value is False)

Boolean
clip_to_elements

If set to True, the layout is clipped to the smallest bounding box that includes all layout elements.

(The default value is False)

Boolean

SVG is an XML-based file format that has been specifically designed for viewing on the web. SVG can contain both vector and raster information. Some web browsers may require a plug-in to view SVG files. Older browsers may not be able to view SVG files at all. SVG supports font embedding, so users who do not have Esri fonts installed can still view SVG exports with proper symbology. You can also choose to produce compressed SVG files. The file extension changes to .svgz when this option is enabled.

exportToTGA (out_tga, {resolution}, {color_mode}, {transparent_background}, {clip_to_elements})
ParameterExplanationData Type
out_tga

A string that represents the path and file name for the output export file.

String
resolution

A number that defines the resolution of the export file in dots per inch (dpi).

(The default value is 96)

Integer
color_mode

This value specifies the number of bits used to describe color.

  • 8-BIT_ADAPTIVE_PALETTE8-bit adaptive palette
  • 8-BIT_GRAYSCALE8-bit grayscale
  • 24-BIT_TRUE_COLOR24-bit true color
  • 32-BIT_WITH_ALPHA32-bit with alpha

(The default value is 32-BIT_WITH_ALPHA)

String
transparent_background

If set to True, the white page background is set to transparent.

(The default value is False)

Boolean
clip_to_elements

If set to True, the layout is clipped to the smallest bounding box that includes all layout elements.

(The default value is False)

Boolean

TGA files have historically been used for content that is meant to be used in other applications (for example, image sprites for animated games) and is read and written by many popular graphic arts applications. TGA format supports multiple bit depths including 32-bit with alpha (transparency) support.

exportToTIFF (out_tif, {resolution}, {color_mode}, {tiff_compression}, {jpeg_compression_quality}, {transparent_background}, {embed_color_profile}, {clip_to_elements}, {world_file}, {geoTIFF_tags}, {georef_mapframe})
ParameterExplanationData Type
out_tif

A string that represents the path and file name of the output export file.

String
resolution

A number that defines the resolution of the export file in dots per inch (dpi).

(The default value is 96)

Integer
color_mode

This value specifies the number of bits used to describe color.

  • 8-BIT_ADAPTIVE_PALETTE8-bit adaptive palette
  • 8-BIT_GRAYSCALE8-bit grayscale
  • 24-BIT_TRUE_COLOR24-bit true color
  • 32-BIT_WITH_ALPHA32-bit with alpha

(The default value is 24-BIT_TRUE_COLOR)

String
tiff_compression

This value represents a compression scheme.

  • DEFLATEA lossless data compression.
  • JPEGJPEG compression.
  • LZWLempel-Ziv-Welch, a lossless data compression.
  • NONECompression is not applied.
  • PACK_BITSPack bits compression.

(The default value is LZW)

String
jpeg_compression_quality

This value (0–100) controls the amount of compression applied to the output image. With a JPEG image, quality is adversely affected the more compression is applied. A higher quality (highest = 100) setting will produce sharper images and larger file sizes. A lower quality setting will produce more image artifacts and smaller files.

(The default value is 80)

Integer
transparent_background

If set to True, the white page background is set to transparent.

(The default value is False)

Boolean
embed_color_profile

If set to True, color profile information is embedded in the image's metadata.

(The default value is True)

Boolean
clip_to_elements

If set to True, the layout is clipped to the smallest bounding box that includes all layout elements.

(The default value is False)

Boolean
world_file

If set to True and a valid georef_mapframe is set, a world file will be generated based on the map frame's coordinate system.

(The default value is False)

Boolean
geoTIFF_tags

If set to True and a valid georef_mapframe is set, geoTIFF tags will be embedded in the resulting image based on the map frame's coordinate system.

(The default value is False)

Boolean
georef_mapframe

If set to True, the layout is clipped to the smallest bounding box that includes all layout elements.

(The default value is None)

MapFrame

TIFF files are the best choice for importing into image editing applications and are also a common GIS raster data format. However, they cannot be natively viewed by a web browser.

getDefinition (cim_version)
ParameterExplanationData Type
cim_version

A string that represents the major version of the CIM.

String

CIM-level access to additional object properties was introduced at version 2.4. Esri follows the semantic versioning specification. This means that until the next major release—for example, 3.0—when breaking API changes are allowed, the value to be used with cim_version is V2. Once 3.0 is released, a new V3 option will become available. This gives Python script authors control over the CIM version that will be used during execution if there is a possibility that breaking changes may be introduced in the new version.

For more information about working with the CIM and samples, see Python CIM Access.

listElements ({element_type}, {wildcard})
ParameterExplanationData Type
element_type

A string that represents the element type that will be used to filter the returned list of elements.

(The default value is None)

String
wildcard

A wildcard is based on the element name and is not case sensitive. A combination of asterisks (*) and characters can be used to help limit the results.

(The default value is None)

String
Return Value
Data TypeExplanation
List

A Python list of page layout elements. The types of objects that can be returned are GraphicElement, LegendElement, MapFrame, MapsurroundElement, PictureElement, and TextElement.

Each page element has a name property that can be set within the element properties dialog box. It is the layout author's responsibility to ensure each page element is given a unique name so that elements can be uniquely identified. If two elements have the same name, there is no way to ensure it is the element you want to reference.

The listElements method will return the elements within a group element into a flattened list. This makes it possible to easily search and replace text strings, for example, without having to navigate through a group element structure.

The element_type parameter can be skipped by passing an empty string or by including the parameter name for all parameters that follow the skipped parameter. For example

elm = lyt.listElements("", "Title")[0]

#or

elm = lyt.listElements(wildcard="Title")[0]

setDefinition (definition_object)
ParameterExplanationData Type
definition_object

A modified CIM definition object originally retrieved using getDefinition.

Object

For more information about working with the CIM and samples, see Python CIM Access.

Code sample

Layout example 1

The following script uses the keyword current, so it should be run from the Python window. The script prints the name of each map in a project and its layers as well as the name of each layout and its page size.

aprx = arcpy.mp.ArcGISProject("CURRENT")
for m in aprx.listMaps():
    print("Map: " + m.name)
    for lyr in m.listLayers():
        print("  " + lyr.name)
print("Layouts:")
for lyt in aprx.listLayouts():
    print(f"  {lyt.name} ({lyt.pageHeight} x {lyt.pageWidth} {lyt.pageUnits})")
Layout example 2

The following script will update a map frame's area of interest by zooming to each bookmark that belongs to a map called Yosemite National Park and exports the result to individual PDF documents.

import arcpy, os
aprx = arcpy.mp.ArcGISProject(r"C:\Projects\YosemiteNP\Yosemite.aprx")

lyt = aprx.listLayouts("Main Attractions*")[0]
mf = lyt.listElements("MAPFRAME_ELEMENT", "Yosemite National Park*")[0]

bkmks = mf.map.listBookmarks()
for bkmk in bkmks:
  mf.zoomToBookmark(bkmk)
  lyt.exportToPDF(os.path.join(r"C:\Projects\YosemiteNP", f"{bkmk.name}.pdf"))
del aprx
Layout example 3

The following script will check for the presence of a map series, then export two of its pages out to PDF.

import arcpy
import os
import sys
relpath = os.path.dirname(sys.argv[0])

p = arcpy.mp.ArcGISProject(relpath + "\\MapSeries\\US_States.aprx")
l = p.listLayouts()[0]
if not l.mapSeries is None:
    ms = l.mapSeries
    if ms.enabled:
        ms.currentPageNumber = ms.getPageNumberFromName("Rhode Island") 
        ms.exportToPDF(relpath + "\\Output\\Ex1_RI.pdf", "CURRENT", resolution=300)
        ms.currentPageNumber = ms.getPageNumberFromName("Washington") 
        ms.exportToPDF(relpath + "\\Output\\Ex1_WA.pdf", "CURRENT")