Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #You're going to need to reference your current map document and the data frame, assuming you just have one
- mxd = arcpy.mapping.MapDocument("CURRENT")
- df = arcpy.mapping.ListDataFrames(mxd)[0]
- #Associate scale bars in your layout with variables that arcpy can manipulate
- m_scale = arcpy.mapping.ListLayoutElements(mxd, "MAPSURROUND_ELEMENT", "m scale bar")[0]
- km_scale = arcpy.mapping.ListLayoutElements(mxd, "MAPSURROUND_ELEMENT", "km scale bar")[0]
- #Iterate through all the pages, for each page, look at the scale, then adjust the scale bars to be on, or off, the page.
- for page in range(1, mxd.dataDrivenPages.pageCount +1):
- #Check the scale and move the elements around to get the right scale bar on the page
- if df.scale < 25000:
- m_scale.elementPositionX = 5 #on the page
- km_scale.elementPostitionX = 15 #off the page
- #Export the current page to a pdf, using a specified path
- arcpy.mapping.ExportToPDF(mxd, r"C:ProjectOutputProject1.pdf", df)
- else:
- m_scale.elementPositionX = 15 #off the page
- km_scale.elementPostitionX = 5 #on the page
- #Export the current page to a pdf, using a specified path
- arcpy.mapping.ExportToPDF(mxd, r"C:ProjectOutputProject1.pdf", df)
- mxd.dataDrivenPages.refresh()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement