AnsweredAssumed Answered

Data Driven Page Export ArcPRO to Image

Question asked by ElPone on Jul 10, 2018

The key issue to me seems to be:


Is not working in arcpro in respect to a row object from a layout mapseries, this worked  just fine in ArcGIS (10.3)



I am trying to automate the export of a data driven page into .png in arcpro.  The issue I am running into working out how to automate the naming of the output .png's.

The naming pattern I want to use is

theOutput = outDir + '\\' + theBase + '_'+str(theNameValue) + ".png"


outDir is an output directory which is passed into the job as a parameter.

theBase is the base file name of the arcpro project and is defined thus

theBase = os.path.splitext(os.path.basename(aprx.filePath))[0]


The issue is arising in setting theNameValue. 

I want to use the value of mapsSeries.pageNameField for the current page the script is iterating through. 


A sample script is attached and requires the following parameters.

outDir = arcpy.GetParameterAsText(0) # Create or use an output directory variable
outRes = arcpy.GetParameterAsText(1) # Resolution of PNG in dpi.
theLayout = arcpy.GetParameterAsText(2) #The layout we want to push out DDPs on.


Now on my test data I happen to have set the map series name field to be a field named: Name (the use case is bridges, but that's not really relevant...) but it is successfully used in line 23



Now according to the help on map series line 20 on the snippet below, theRow should be returning a row object.   

Checking what theRow is via line24 returns:  [0, 'Aughnacrew Bridge Culvert', 'BR01', ' ']


on the test data I was using this is expected.  According to the help on row objects this should have a method

getValue (field_name)

that Gets the field value....


However when I try to use it like in line 26:


It will cause the code to fail like the image below and as far as I can tell this should work.


Can anyone help me understand why this is not working?  


I have managed to get this script to  sort of work by calling


But this does not strike me as good form.

I am using ArcPRO 2.2.0


for lyt in aprx.listLayouts(theLayout):
    if == theLayout:
        #we check we are hitting on our desired
        if  lyt.mapSeries is not None:
            ms = lyt.mapSeries
            idxLyer = ms.indexLayer
            idxLyerName =
            if ms.enabled:
                arcpy.AddMessage("\n\tMap Doc is data driven page.\n\tAll good to proceed")
                #get the name field.
                theNameField =
                test = ms.pageNameField
                #get the number of pages to use for push out
                for pageNum in range(1,ms.pageCount + 1):
                    #make the page the current page number..
                    ms.currentPageNumber = pageNum
                    theRow = ms.pageRow
                    fields = arcpy.ListFields(idxLyerName)
                    arcpy.AddMessage(theRow)    #seeing what row contains
                    arcpy.AddMessage(theRow[1]) #access row by index
                    #arcpy.AddMessage(theRow.getValue(theNameField))    #This causing fail
                    arcpy.AddMessage(dir(theRow))   #find out what methods and attributes theRow has.
                    arcpy.AddMessage(theRow.__getattribute__(theNameField)) #This works?
                    arcpy.AddMessage("where is this going wrong?")
                    theOutput = outDir + '\\' + theBase + '_'+str(theRow.__getattribute__(theNameField)) + ".png"

geoprocessing fail due to line:arcpy.AddMessage(theRow.getValue(theNameField))