exporting layout view in arcpy

3670
2
03-27-2013 09:51 AM
courtneygarlock
New Contributor II
Hi,

I am trying to export the layout view in arcmap by using the following script:

import arcpy
import os

mxd = arcpy.mapping.MapDocument(r"C:\Project\Project.mxd")
df = arcpy.mapping.ListDataFrames(mxd, "Traffic Analysis")[0]
df.time.currentTime = df.time.startTime

while df.time.currentTime <= df.time.endTime:
    # An example str(newTime) would be: "2008-12-29 02:19:59"
    # The following line splits the string at the space and takes the first
    # item in the resulting string. 
    fileName = str(df.time.currentTime).split(" ")[0] + ".jpg"
    arcpy.mapping.ExportToJPEG(mxd, os.path.join(r"C:\Project\Output", fileName), df)
    df.time.currentTime = df.time.currentTime + df.time.timeStepInterval
del mxd

This only exports the "data veiw" map but I want the "layout view"

Is python cabable of this....

I can set the mxd.activeView = 'PAGE_LAYOUT'
so when the mxd is opened it always opens to the page layout. I thougth that would allow images to export from that page but it
doesn't seem to be the case.

Is it possible??
Tags (2)
0 Kudos
2 Replies
MathewCoyle
Frequent Contributor
You are having issues because you are specifying a dataframe to export. You cannot export a dataframe by layout view.

arcpy.mapping.ExportToJPEG(mxd, os.path.join(r"C:\Project\Output", fileName), df)


You can read the help on the tool here to get the proper parameter.
http://resources.arcgis.com/en/help/main/10.1/index.html#//00s300000038000000
0 Kudos
courtneygarlock
New Contributor II
Thank you,

It almost works,

I set data_frame = "PAGE_LAYOUT" and took out df and replaced with data_frame

It is now exporting the layout view with all text and mapsurround elements etc... but NOT the data (time enabled layer file)

Do you know why this is? is it bc i'm not calling the dataframe anymore?