Advertisement
Guest User

Untitled

a guest
Jun 25th, 2019
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.26 KB | None | 0 0
  1. #You're going to need to reference your current map document and the data frame, assuming you just have one
  2. mxd = arcpy.mapping.MapDocument("CURRENT")
  3. df = arcpy.mapping.ListDataFrames(mxd)[0]
  4.  
  5. #Associate scale bars in your layout with variables that arcpy can manipulate
  6. m_scale = arcpy.mapping.ListLayoutElements(mxd, "MAPSURROUND_ELEMENT", "m scale bar")[0]
  7. km_scale = arcpy.mapping.ListLayoutElements(mxd, "MAPSURROUND_ELEMENT", "km scale bar")[0]
  8.  
  9. #Iterate through all the pages, for each page, look at the scale, then adjust the scale bars to be on, or off, the page.
  10. for page in range(1, mxd.dataDrivenPages.pageCount +1):
  11.  
  12. #Check the scale and move the elements around to get the right scale bar on the page
  13. if df.scale < 25000:
  14. m_scale.elementPositionX = 5 #on the page
  15. km_scale.elementPostitionX = 15 #off the page
  16.  
  17. #Export the current page to a pdf, using a specified path
  18. arcpy.mapping.ExportToPDF(mxd, r"C:ProjectOutputProject1.pdf", df)
  19. else:
  20. m_scale.elementPositionX = 15 #off the page
  21. km_scale.elementPostitionX = 5 #on the page
  22.  
  23. #Export the current page to a pdf, using a specified path
  24. arcpy.mapping.ExportToPDF(mxd, r"C:ProjectOutputProject1.pdf", df)
  25. mxd.dataDrivenPages.refresh()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement