ArcPy Data Driven Page Extents (2 data frames)

02-13-2019 07:28 AM
New Contributor


I have an MXD with two data frames. I want to use Data Driven Pages (DDP) to export this to PDF but have the second of the data frames be one extent ahead. I have the following script to export the two frames with the same extent using DDP. I want to have frame2 be one ahead of the DDP page of the master frame. Any ideas?

#set map document
mxd = arcpy.mapping.MapDocument("CURRENT")

#set master data frame - dataframe with DDP already applied
masterFrame = arcpy.mapping.ListDataFrames(mxd)

#set second data frame to copy master
frame2 = arcpy.mapping.ListDataFrames(mxd,"New Data Frame")

#for loop to process DDP using number of pages
for pageNum in range(1, mxd.dataDrivenPages.pageCount + 1):
   #mxd.dataDrivenPages.currentPageID = pageNum
   frame2[0].extent = masterFrame[0].extent
   arcpy.mapping.ExportToPDF(mxd, r"C:\Users\user\Desktop\a\"+ str(pageNum) + '.pdf')

Tags (2)
0 Kudos
0 Replies