Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

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.

share|improve this question
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

1 Answer 1

Try using these two methods within your search cursor:



zoomToSelectedFeatures ()

To zoom to the index feature record.

share|improve this answer
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

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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