import arcpy mxd = arcpy.mapping.MapDocument("CURRENT") topDF = arcpy.mapping.ListDataFrames(mxd, "Top")[0] bottomDF = arcpy.mapping.ListDataFrames(mxd, "Bottom")[0] for DDP_Page in range(1, (mxd.dataDrivenPages.pageCount + 1)): mxd.dataDrivenPages.currentPageID = DDP_Page angle = mxd.dataDrivenPages.pageRow.angle bottomDF.rotation = angle
Solved! Go to Solution.
import arcpy mxd = arcpy.mapping.MapDocument("CURRENT") topDF = arcpy.mapping.ListDataFrames(mxd, "Top")[0] bottomDF = arcpy.mapping.ListDataFrames(mxd, "Bottom")[0] for DDP_Page in range(1, (mxd.dataDrivenPages.pageCount + 1)): mxd.dataDrivenPages.currentPageID = DDP_Page angle = mxd.dataDrivenPages.pageRow.angle bottomDF.rotation = angle arcpy.mapping.ExportToPDF(mxd, r"C:\project\Map_20k_B" + str(DDP_Page) + ".pdf")
import arcpy mxd = arcpy.mapping.MapDocument("CURRENT") topDF = arcpy.mapping.ListDataFrames(mxd, "Top")[0] bottomDF = arcpy.mapping.ListDataFrames(mxd, "Bottom")[0] for DDP_Page in range(1, (mxd.dataDrivenPages.pageCount + 1)): mxd.dataDrivenPages.currentPageID = DDP_Page angle = mxd.dataDrivenPages.pageRow.angle bottomDF.rotation = angle arcpy.mapping.ExportToPDF(mxd, r"C:\project\Map_20k_B" + str(DDP_Page) + ".pdf")
Wouldn't this only be the case if you save the MXD? If the objective is to export to PDF, then run the script, export, and don't save changes. This tool may be better off running as a script tool where you can enter an index value and have it just export that page (or a range of pages).
It would be a good idea to added match data frame rotation to the ideas.esri.com site.
Jeff
I was wondering if you could edit the script for me so I could add a page range?
for DDP_Page in range(1, (mxd.dataDrivenPages.pageCount + 1)):
for DDP_Page in range(2, 5)):
Hi Jeff,
I found only this 7 years old topic when I tried to find the answer about DDP setting rotation angle.
Can you help me with this?
My exactly question is: I have single layout with 4 data frames (A,B,C,D). In layout mode I enabled DDP and set the rotation angle column from attribute table for data frame A. When I drive pages in layout other data frames moves as well but does not have the rotation angle as I have in frame A. Is it possible to have the same rotation angle for all frames when I change pages?
Thank you for your valuable time and response.
Orkhan,
It is the same code as the original script but you are just referencing additional data frames.
import arcpy mxd = arcpy.mapping.MapDocument("CURRENT")
Main_DF = arcpy.mapping.ListDataFrames(mxd, "Main DF")[0]
DF_B = arcpy.mapping.ListDataFrames(mxd, "B")[0]
DF_C = arcpy.mapping.ListDataFrames(mxd, "C")[0]
DF_D = arcpy.mapping.ListDataFrames(mxd, "D")[0]
for DDP_Page in range(1, (mxd.dataDrivenPages.pageCount + 1)):
mxd.dataDrivenPages.currentPageID = DDP_Page
angle = mxd.dataDrivenPages.pageRow.angle
DF_B.rotation = angle
DF_C.rotation = angle
DF_D.rotation = angle
Jeff,
" arcpy.mapping.ListDataFrames(mxd, "Main DF")[0] "
Above shown line gave error, couldn't figure out what can be the issue in that line?
I simply copy you code to python window of arcmap and tried to run (only changed layer name from A to Morphology, B to Contour)
"Main DF" is a wildcard search for the name of the data frame. You may be searching for a data frame with a different name.