Select to view content in your preferred language

arcpy.mapping Runtime error

1110
2
07-17-2013 02:21 PM
YanetCuddus
New Contributor
Hi, I am new to this and keep getting the same error 😕

# Trying to export DDP individual high quality PDF files, after renaming and re numbering the pgs to start from #6

>>> mxd = arcpy.mapping.MapDocument("CURRENT")

>>> df = arcpy.mapping.ListDataFrames(mxd)

... for pageNum in range(1, mxd.dataDrivenPages.pageCount + 1):

...   mxd.dataDrivenPages.currentPageID = pageNum

...   print "Exporting page {0} of {1}".format(int(mxd.dataDrivenPages.currentPageID), int(mxd.dataDrivenPages.pageCount))

...   arcpy.mapping.ExportToPDF(mxd, ("C:/Users/cuydls/Documents/ArcGIS/Lease_Book/Output/LeaseBook_"+(pageNum+5) + ".pdf"),df,5100,3300,300,"BEST","RGB",1,"ADAPTIVE","RASTERIZE_BITMAP",0,1,"LAYERS_ONLY",1,80)

... del mxd

#Keep getting:  Runtime error <type 'exceptions.TypeError'>: cannot concatenate 'str' and 'int' objects
# Can anyone help me?
0 Kudos
2 Replies
JasonScheirer
Esri Alum
Need to change pageNum to a string; str(pageNum+5)

 arcpy.mapping.ExportToPDF(mxd, ("C:/Users/cuydls/Documents/ArcGIS/Lease_Book/Output/LeaseBook_"+str(pageNum+5) + ".pdf"),df,5100,3300,300,"BEST","RGB",1,"ADAPTIVE","RASTERIZE_BITMAP",0,1,"LAYERS_ONLY",1,80)
0 Kudos
YanetCuddus
New Contributor
Need to change pageNum to a string; str(pageNum+5)

 arcpy.mapping.ExportToPDF(mxd, ("C:/Users/cuydls/Documents/ArcGIS/Lease_Book/Output/LeaseBook_"+str(pageNum+5) + ".pdf"),df,5100,3300,300,"BEST","RGB",1,"ADAPTIVE","RASTERIZE_BITMAP",0,1,"LAYERS_ONLY",1,80)


Thanks for your help... I added the string declaration as you suggested but now I get this error... "Parsing error <type 'exceptions.IndentationError'>: expected an indented block (line 2)"

Here's the whole code.
>>> mxd = arcpy.mapping.MapDocument("CURRENT")
>>> df = arcpy.mapping.ListDataFrames(mxd)
>>> for pageNum in range (1, mxd.dataDrivenPages.pageCount +1):
... mxd.dataDrivenPages.currentPageID = pageNum
... print "Exporting page {0} of {1}".format(str(mxd.dataDrivenPages.currentPageID), str(mxd.dataDrivenPages.pageCount))
... arcpy.mapping.ExportToPDF(mxd, ("C:/Users/cuydls/Documents/ArcGIS/Lease_Book/Output/LeaseBook_"+str(pageNum+5) + ".pdf"),df,5100,3300,300,"BEST","RGB",1,"ADAPTIVE","RASTERIZE_BITMAP",0,1,"LAYERS_ONLY",1,80)
...
Parsing error <type 'exceptions.IndentationError'>: expected an indented block (line 2)
>>>
0 Kudos