yycuddus

Script: export DDP to PDF but sorting by a field in attribute table of Grid Index

Discussion created by yycuddus on Aug 14, 2013
Latest reply on Sep 18, 2013 by msayler
I am new to scripting and I hit a wall at every turn. What am I doing wrong?

There are two parameters:  1) Select Map Document to Print,   2) Select Output File Location

import arcpy, os, sys, string

#Read input parameters from script tool
mxdPath = arcpy.GetParameterAsText(0)
outputlocation = arcpy.GetParameterAsText(1)

#Reference the map and the data driven page object
mxd = arcpy.mapping.MapDocument(mxdPath)
for pageNum in range(1, mxd.dataDrivenPages.pageCount + 1):
   mxd.dataDrivenPages.currentPageID = pageNum

# Get the row from the attribute table of the index layer
  row = mxd.dataDrivenPages.pageRow

  # Get the value from the field called PageName
  name = row.getValue("PageName")

  # Concatenate into whole path name
  outputName = outputlocation + "\\" + name + "_ArcMap" + ".pdf" 

  # Export to PDF
ddp.exportToPDF (outputName, CURRENT",1,"PDF_SINGLE_FILE",300,"BEST","RGB",1,"ADAPTIVE","RASTERIZE_BITMAP",0,1,"LAYERS_ONLY",1,80)

# Clean up
del mxd


Untimately I want to build on it and do a filter so I only print pages that pass the query "Type" LIKE 'Vertical Map'.

I have tried it a couple of ways and I am lost in the weeds.

Outcomes