I am able to zoom into map_index shapefile rows for a group of mxd documents in layoutview and export zoomed record as a PDF document at the same time. I tried to combine below codes to make the procedure possible but no luck.

Below code is for zooming into map_index shapefile row values in layout view.

import arcpy
mxd = arcpy.mapping.MapDocument('CURRENT')
df = arcpy.mapping.ListDataFrames(mxd, "Layers") [0]
for row in arcpy.SearchCursor("C:\Users\Desktop\Maps\map_index.shp"):
  df.extent = row.SHAPE.extent 
  df.scale = df.scale 

for df in arcpy.mapping.ListDataFrames(mxd):
mxd.activeView = df.name
mxd.title = df.name
mxd.saveACopy(r"C:\Users\Desktop\Deneme\\" + df.name + ".mxd")

Below codes is the export to PDF document

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

Can any one help me please? I dont know if its possible but any help would be appreciated.

  • 1
    Will this be part of a larger script? It seems like the functionality that you are trying to code for is already built into Data Driven Pages. Once DDP is set up, it will loop through your "indexLayer" and export the map to PDF. Currently (for Arc10 and DDP), PDF is the only export option. – Czed Jan 8 '13 at 16:57
  • which error are you getting? – ako Mar 9 '13 at 19:57
  • This is an old question but you have provided very little context about what you are trying to do, and what happens when you run your code, so I am unclear about where you are stuck. – PolyGeo Feb 22 '15 at 7:41

Try using these two methods within your search cursor:



zoomToSelectedFeatures ()

To zoom to the index feature record.

  • Hi all, thank you for your help but i need to combine these two codes. help me please. – Bilgehan Meral Jan 8 '13 at 19:27

Not the answer you're looking for? Browse other questions tagged or ask your own question.