1

We have a data driven pages enabled MXD. Refreshing this mxd in arcmap works and gives me 9000+ pages. Via python however, mxd.dataDrivenPages.pageCount returns 0. Even after mxd.dataDrivenPages.refresh().

In ArcGIS resources, they say:

Four elements are required for the creation of Data Driven Pages. They are:

Detail Data Frame, Index Layer, Name Field, Sort Field

In ArcMap I use the FILENAME option in the Name Field. In python, I find that mxd.dataDrivenPages.pageNameField is None. But I'm unable to set this property. Any ideas on what to look for to get my pages via python?

Code is:

import arcpy, oss

logger = oss.log()

mxd = arcpy.mapping.MapDocument(MxdFile)
ddp = mxd.dataDrivenPages
logger.info('Checking required params')
logger.info('dataFrame is : "%s"' % mxd.dataDrivenPages.dataFrame)
logger.info('currentpageid is : "%s"' % mxd.dataDrivenPages.currentPageID)
logger.info('index layer is "%s"' % dpp.indexlayer)
logger.info('pagenamefield : "%s"' % mxd.dataDrivenPages.pageNameField)

logger.info('Refreshing index layer')
ddp.refresh()
logger.info('ddp number after refresh : "%s"' % mxd.dataDrivenPages.pageCount)

This results in:

INFO - Checking required params
INFO - dataFrame is : "<geoprocessing Data Frame object object at 0x0000000010CC
6970>"
INFO - currentpageid is : "0"
INFO - index layer is "VISION.SWG_WPA_MAP_ATLAS_TB"
INFO - pagenamefield : "None"
INFO - Refreshing index layer
INFO - ddp number after refresh : "0"
  • Could you post your python code? – GISKid Jul 17 '14 at 15:14
  • Added to question! – GeoSolve Jul 17 '14 at 15:27
  • What happens when you eliminate logger from your code snippet? – PolyGeo Dec 23 '16 at 7:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.