4

I have a problem in Data Driven Pages In my Mxd proyect I have 3 Data frames, each frame has 3 layers with their respective legends. I already activated the process of Data Driven Pages to export a single data frame with Python code, however, I need to export the other Data frames with their layers in png or pdf at the same time.

Can I export multiple data frames (with python code) and their respective layers in jpg or pdf?

This the code to export only one data frame:

mxd = arcpy.mapping.MapDocument("CURRENT") 
for pageNum in range(1, mxd.dataDrivenPages.pageCount + 1):
  mxd.dataDrivenPages.currentPageID = pageNum
  arcpy.mapping.ExportToPNG(mxd, r:c\\") ##<--- my path

but, I don´t know how export the other data frames using this code.

3

I suspect that you had your map saved in Data View when you ran your code and saw the undesirable result so:

  1. Open your MXD in ArcMap
  2. Switch to Layout View
  3. Save your map
  4. Run your ArcPy script

Alternatively, and probably preferably, do it all within ArcPy by changing:

mxd = arcpy.mapping.MapDocument("CURRENT") 

to:

mxd = arcpy.mapping.MapDocument("CURRENT")
mxd.activeView = "PAGE_LAYOUT"

The activeView property is documented under MapDocument.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.