I have found two workarounds for this issue.
1. Create several MXD map documents. One for each set of maps that share a common scale, with the grids and graticules as desired.- Use ArcPy to export them all as individual PDF pages and collate them together in the right order.
2. Use one MXD map document with several data frames. The first data frame contains the data and DDP index layer. Subsequent data frames with no data, but with a grid/graticule.- The subsequent data frames are created exactly on top of the first data frame with the same page dimensions in the layout view. The extent is set to be derived from the first data frame, and the name includes the scale that they are suitable for. Once checked that these grid/graticule data frames look OK, offset them by a set amount (say -40cm in the X plane) so they don't appear in the layout view and slow ArcMap down.
- Then use an ArcPY script to cycle through the DDP. For each page, check the scale (taken from a scale attribute in the DDP index layer) against the data frame name. When a scale matches a grid/graticule data frame, move it directly over the map, export the pdf page, and then move it back again.
Here is a copy of my current code for the second method, designed to be used with a script tool. A lot of parts are still hard-coded, so I'm sure it could be improved.
Code:
# Import arcpy module
import arcpy
# Read the parameter values:
# 1: Input MXD
# 2: Output folder
# 3. Output filename
mxdPath = arcpy.GetParameterAsText(0)
outDir = arcpy.GetParameterAsText(1)
outFile = arcpy.GetParameterAsText(2)
arcpy.AddMessage("Processing: "+mxdPath)
mxd = arcpy.mapping.MapDocument(mxdPath)
# Get data frames from mxd
dfs = arcpy.mapping.ListDataFrames(mxd)
# Assume first data frame is the map (HARDCODED) and get the x page offset
x = dfs[0].elementPositionX
#Create final output PDF file
finalPdf = arcpy.mapping.PDFDocumentCreate(outDir + "\\" + outFile + ".pdf")
# Cycle through DDP in mxd
pageCount = mxd.dataDrivenPages.pageCount
for pageNum in range(1, pageCount + 1):
mxd.dataDrivenPages.currentPageID = pageNum
# Get scale from DDP index layer (HARDCODED - assumes "Scale" attribute exists)
scale = mxd.dataDrivenPages.pageRow.Scale
# Move Grids & Graticules in position for each scale (HARDCODED - data frames must have certain names)
for df in dfs:
if (df.name == "Graticule_"+str(scale)) or (df.name == "Grid_"+str(scale)):
df.elementPositionX = x
arcpy.AddMessage("Exporting page {0} of {1}".format(str(pageNum), str(pageCount)))
tmpPdf = outDir + "\\" + "temp.pdf"
arcpy.mapping.ExportToPDF(mxd, tmpPdf)
finalPdf.appendPages(tmpPdf)
# Move Grids & Graticules back to original position (HARDCODED -40cm assumed)
for df in dfs:
if (df.name == "Graticule_"+str(scale)) or (df.name == "Grid_"+str(scale)):
df.elementPositionX = -40
del tmpPdf
arcpy.AddMessage("Saving: " + outFile + ".pdf")
finalPdf.saveAndClose()
Karl
Bookmarks