Sign up ×
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 =
mxd.title =
mxd.saveACopy(r"C:\Users\Desktop\Deneme\\" + + ".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

closed as unclear what you're asking by PolyGeo Feb 22 at 7:39

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question.If this question can be reworded to fit the rules in the help center, please edit the 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
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 at 7:41

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

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