I'm trying to use DDP (Data Driven Pages) and am running into a problem. I'm using arcpy.SelectLayerByAttribute_management to select a series of records, and then trying to use the ddp.exportToPDF(pdfddp, "SELECTED") but keep running into an error (below). It shouldn't be the select by attribute function as I run it in ArcMap and it runs correctly and I can see the selected features highlighted. Also, I can successfully use the ddp.exportToPDF(pdfddp, "CURRENT") but what I need is to be able to have a user select a series of features and have those be passed.
mxd = arcpy.mapping.MapDocument("C:\\temp\\Graffiti_DM4.mxd") df = arcpy.mapping.ListDataFrames(mxd, "*") pdfddp="C:\\temp\\pdfddp1.pdf" arcpy.SelectLayerByAttribute_management("C:\\temp\\test.lyr","NEW_SELECTION", '"Incident_Z" =' + "'10002'") ddp.exportToPDF(pdfddp, "SELECTED")
And here is the error
Runtime error Traceback (most recent call last): File "<string>", line 1, in <module> File "c:\program files\arcgis\desktop10.1\arcpy\arcpy\utils.py", line 181, in fn_ return fn(*args, **kw) File "c:\program files\arcgis\desktop10.1\arcpy\arcpy\_mapping.py", line 446, in exportToPDF return convertArcObjectToPythonObject(self._arc_object.exportToPDF(*gp_fixargs((out_pdf, page_range_type, page_range_string, multiple_files, resolution, image_quality, colorspace, compress_vectors, image_compression, picture_symbol, convert_markers, embed_fonts, layers_attributes, georef_info, jpeg_compression_quality, show_selection_symbology), True))) AttributeError: PageLayoutObject: Error in exporting pages
As always, any help is EXTREMELY appreciated!