Skip to main content
Indentation error
Source Link
Jason Scheirer
  • 18k
  • 2
  • 54
  • 72

I'm simply reposting the code from above as an answer because I found it really useful but it took ages to find:

import_path = (r"..."   # Path of .mxd
export_path = (r"..."   # Path of output file
field_name = "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)
   arcpy.mapping.ExportToJPEG(mxd, export_path + "." + row.getValue(field_name) + ".jpg") 
del mxd

I'm simply reposting the code from above as an answer because I found it really useful but it took ages to find:

import_path = (r"..."   # Path of .mxd
export_path = (r"..."   # Path of output file
field_name = "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)
arcpy.mapping.ExportToJPEG(mxd, export_path + "." + row.getValue(field_name) + ".jpg") 
del mxd

I'm simply reposting the code from above as an answer because I found it really useful but it took ages to find:

import_path = r"..."   # Path of .mxd
export_path = r"..."   # Path of output file
field_name = "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)
   arcpy.mapping.ExportToJPEG(mxd, export_path + "." + row.getValue(field_name) + ".jpg") 
del mxd
added 6 characters in body
Source Link
MAJ742
  • 3.8k
  • 24
  • 38

I'm simply reposting the code from above as an answer because I found it really useful but it took ages to find:

import_path = (r"..."   # Path of .mxd
export_path = (r"..."   # Path of output file
field_name = "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)
arcpy.mapping.ExportToJPEG(mxd, export_path + "." + row.getValue(field_name) + ".jpg") 
del mxd

I'm simply reposting the code from above as an answer because I found it really useful but it took ages to find:

import_path = (r"..."   # Path of .mxd
export_path = (r"..."   # Path of output file
field_name = "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
   row.getValue(field_name)
arcpy.mapping.ExportToJPEG(mxd, export_path + "." + row.getValue(field_name) + ".jpg") 
del mxd

I'm simply reposting the code from above as an answer because I found it really useful but it took ages to find:

import_path = (r"..."   # Path of .mxd
export_path = (r"..."   # Path of output file
field_name = "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)
arcpy.mapping.ExportToJPEG(mxd, export_path + "." + row.getValue(field_name) + ".jpg") 
del mxd
Source Link
MAJ742
  • 3.8k
  • 24
  • 38

I'm simply reposting the code from above as an answer because I found it really useful but it took ages to find:

import_path = (r"..."   # Path of .mxd
export_path = (r"..."   # Path of output file
field_name = "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
   row.getValue(field_name)
arcpy.mapping.ExportToJPEG(mxd, export_path + "." + row.getValue(field_name) + ".jpg") 
del mxd