AnsweredAssumed Answered

ExportingToPDF Python for Map Series

Question asked by FranklinCountyPaGIS on May 30, 2019
Latest reply on Jun 18, 2019 by FranklinCountyPaGIS

I am attempting to export a range of sheets in a map series in ArcPro.  I'm basing my code off ESRI's code sample 2 here https://pro.arcgis.com/en/pro-app/arcpy/mapping/mapseries-class.htm.

 

import arcpy, os, sys
relpath = r"S:\Tax Services\Tax Maps"

aprx = arcpy.mp.ArcGISProject(r"S:\FC GIS\GIS Projects\New Tax Maps\Tax Map DDP\Tax Map DDP - new.aprx")
l = p.listLayouts()[1]
if not l.mapSeries is None:
  ms = l.mapSeries
  if ms.enabled:
    for pageNum in range(1, 5):
      ms.currentPageNumber = pageNum
      print("Exporting {0}".format(ms.pageRow.Page))
      pageName = ms.pageRow.Page
      l.exportToPDF(relpath + "MapSheet_{0}".format(ms.pageRow.page) + ".pdf")

 

However, I keep getting the following error:

---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-3-2671737b67ee> in <module>()
      9         for pageNum in range(1, 5):
     10           ms.currentPageNumber = pageNum
---> 11           print("Exporting {0}".format(ms.pageRow.Page))
     12           pageName = ms.pageRow.Page
     13           l.exportToPDF(relpath + "MapSheet_{0}".format(ms.pageRow.Page) + ".pdf")

C:\Program Files\ArcGIS\Pro\Resources\ArcPy\arcpy\_mp.py in pageRow(self)
   2240     @property
   2241     def pageRow(self):
-> 2242       return self.convert(convertArcObjectToPythonObject(getattr(self._arc_object, "pageRow")))
   2243
   2244

C:\Program Files\ArcGIS\Pro\Resources\ArcPy\arcpy\_mp.py in convert(self, dictionary)
   2236     def convert(self, dictionary):
   2237       from collections import namedtuple
-> 2238       return namedtuple('pageRow', dictionary.keys())(**dictionary)
   2239
   2240     @property

C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\lib\collections\__init__.py in namedtuple(typename, field_names, verbose, rename, module)
    399         if not name.isidentifier():
    400             raise ValueError('Type names and field names must be valid '
--> 401                              'identifiers: %r' % name)
    402         if _iskeyword(name):
    403             raise ValueError('Type names and field names cannot be a '

ValueError: Type names and field names must be valid identifiers: 'Shape.STArea()'

 

Any help would be appreciated!

Outcomes