AnsweredAssumed Answered

Exporting Data Driven Pages to JPEG - modeling export location as parameter

Question asked by Jerry_G on Feb 17, 2016
Latest reply on Feb 18, 2016 by Playa

Hello,

 

I am still new to Python and I am stuck on how to allow the user of the tool to set the location of the resulting JPEGs. The script I have so far is below

 

import arcpy,os,sys

import arcpy.mapping

import arcpy.utils

import arcpy.arcobjects

 

 

import_path = r"C:\GIS_DATA\Python_Scripts\python_jpeg_example.mxd"   # Path of .mxd

export_path = r"C:\GIS_DATA\Python_Scripts"   # Path of output file

field_name = "DIST_NAME" # Name of field used to sort DDP

 

 

mxd = arcpy.mapping.MapDocument(import_path)

for i in range(1, mxd.dataDrivenPages.pageCount + 1):

   mxd.dataDrivenPages.currentPageID = i

   row = mxd.dataDrivenPages.pageRow

   print row.getValue(field_name)

   print export_path + "." + row.getValue(field_name) + ".jpg"

   arcpy.mapping.ExportToJPEG(mxd, export_path + "." + row.getValue(field_name) + ".jpg")

del mxd

 

 

When adding the tool in I set the export path as a parameter (set to workspace). No mater where it is set it always drops it in c:\GIS_DATA.  I thought I could use GetParameterAsText but I want the user to navigate to the folder they want the JPEGs to reside instead of having to type in the location.

 

Any help would be greatly appreciated. 

Outcomes