I am trying to create a dynamic map book based on user defined geometry. I can use Grid Index and calculate adjacent tool to create the grids in my Python script. How can I set this newly created grid as Index layer under 'Enable Data Driven Pages'?
if MultiPages.lower()!='no' :
## create Grid based on added geometry (in_buffer)
Gridlr = "gridlr.shp"
Gridlrshp = os.path.join(scratch, Gridlr)
arcpy.GridIndexFeatures_cartography(Gridlrshp, in_buffer, "", "", "", "200 Meters", "200 Meters")
## calculate adjacent fields
arcpy.CalculateAdjacentFields_cartography(Gridlrshp, "PageNumber")
## add the new geometry and grid layer to MXD by replacing the datasources
##print the pdf
outputLayoutPDFMM = os.path.join(scratch, 'multipage.pdf')
ddMMDDP.exportToPDF(outputLayoutPDFMM, "ALL")
