AnsweredAssumed Answered

DataDrivenPages exporting a selection

Question asked by jpedder on Dec 13, 2012
Latest reply on Dec 14, 2012 by jpedder
I'm working through the examples in the online help, example #3 shows how to export a selection of records rather than everything.
import arcpy mxd = arcpy.mapping.MapDocument(r"C:\Project\ParcelAtlas.mxd") ddp = mxd.dataDrivenPages indexLayer = ddp.indexLayer arcpy.SelectLayerByAttribute_management(indexLayer, "NEW_SELECTION",                                           '"PageNumber" >= 1 AND "PageNumber" <= 10') for indexPage in ddp.selectedPages:   ddp.currentPageID = indexPage   ddp.exportToPDF(r"C:\Project\Output\Page" + str(indexPage) + ".pdf", "CURRENT")  del mxd


I have DDP setup on a mxd and when I run the script it always exports ALL the records. The changes I made to the script only pertain to the mxd patch, destination path and field name that is the index layer.

import arcpy mxd = arcpy.mapping.MapDocument(r"C:\MapSAR\New_Incident_Z11\Map_Templates\MapSAR_ANSI_A_8x11_Letter_Landscape_DDP.mxd") ddp = mxd.dataDrivenPages indexLayer = ddp.indexLayer arcpy.SelectLayerByAttribute_management(indexLayer, "NEW_SELECTION",'"Assignment_Number" > 1 AND "Assignment_Number" < 3') for indexPage in ddp.selectedPages:   ddp.currentPageID = indexPage   ddp.exportToPDF(r"C:\MapSAR\New_Incident_Z11\Products\page" + str(indexPage) + ".pdf", "CURRENT")  del mxd


can anyone either point out what I'm doing incorrectly or even better if there's other code examples I might learn from.

Thanks

Jon

Outcomes