Arcpy Map Series- export using page name as output?

530
3
02-21-2018 06:19 AM
TheodoreF
Occasional Contributor II

ArcGIS Pro 2.1.1, python 3.6.2

I have a standalone python script which cycles through multiple map extents and exports each as seperate PDF files. However, currently the PDFs are exported as FILENAME_[Page Number].pdf. I want it to be FILENAME_[Page Name].pdf

Is it as simple as replacing 'ms.currentPageNumber' and 'pageNum' with 'ms.currentPageName' and 'pageNam'? (if those even exists!)

I guess the {0} would also need to disappearin the last line, as there won't be any page number in the file name.

import arcpy, os, sys
relpath = os.path.dirname(sys.argv[0])

p = arcpy.mp.ArcGISProject("C:\\Automation\\Automation.aprx")
print ("project located")
l = p.listLayouts()[0]
print ("layouts listed")
if not l.mapSeries is None:
  ms = l.mapSeries
  if ms.enabled:
    for pageNum in range(1, ms.pageCount + 1):
      ms.currentPageNumber = pageNum
      print("Exporting page {0} of {1}".format(str(ms.currentPageNumber), str(ms.pageCount)))
      l.exportToPDF("C:\\Users\\Default\\Production\\Completed_certificates\\FILENAME_{0}".format(str(ms.currentPageNumber) + ".pdf"))
Tags (2)
0 Kudos
3 Replies
TheodoreF
Occasional Contributor II

replacing all ms.currentPageNumber instances with ms.currentPageName doesn't work, as the latter doesn't exist within arcpy python 3.6.2

0 Kudos
DanPatterson_Retired
MVP Esteemed Contributor

In Pro, under Map series

Methods getPageNumberFromName(page_name)

Properties

currentPageNumber—Read/Write; Long

pageNameField—Read-only; GP Field object   ### try the Field object if so defined

0 Kudos
TheodoreF
Occasional Contributor II

yeah I noticed those, but I don't know how to use them or where to implement them in my script...

0 Kudos