Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import arcpy, os
- #Map document stuff
- CurrentMXD = arcpy.mapping.MapDocument("CURRENT")
- CurrentDF = CurrentMXD.activeDataFrame
- #Output map directory
- Output_dir = "C:temp"
- #Iterate through layer names
- LayersToExport = ["1938 HISTORICAL TOPOGRAPHIC MAP","1940 HISTORICAL TOPOGRAPHIC MAP"]
- for LayerName in LayersToExport:
- #Get current layer, make visible
- Layer = arcpy.mapping.ListLayers(CurrentMXD, LayerName, CurrentDF)[0]
- Layer.visible = True
- #Change title text
- TextElement = arcpy.mapping.ListLayoutElements(CurrentMXD, "TEXT_ELEMENT","TitleText")[0]
- TextElement.text = Layer.name
- #Get output JPG filename, remove existing, export
- Output_jpg = os.path.join(Output_dir,LayerName+".jpg")
- if os.path.exists(Output_jpg): os.remove(Output_jpg)
- arcpy.mapping.ExportToJPEG(CurrentMXD, Output_jpg, resolution=300, jpeg_quality=95)
- #Make layer invisible again
- Layer.visible = False
- >>> import arcpy, os
- #Map document stuff
- CurrentMXD = arcpy.mapping.MapDocument("CURRENT")
- CurrentDF = CurrentMXD.activeDataFrame
- #Output map directory
- Output_dir = "C:Temp"
- #Iterate through layer names
- LayersToExport = ["1943 HISTORICAL TOPOGRAPHIC MAP", "1951 HISTORICAL TOPOGRAPHIC MAP", "1968 HISTORICAL TOPOGRAPHIC MAP"]
- for LayerName in LayersToExport:
- #Get current layer, make visible
- Layer = arcpy.mapping.ListLayers(CurrentMXD, LayerName, CurrentDF)[0]
- Layer.visible = True
- #Change title text
- TextElement = arcpy.mapping.ListLayoutElements(CurrentMXD, "TEXT_ELEMENT","TitleText")[0]
- TextElement.text = Layer.name
- Output_pdf = os.path.join(Output_dir,LayerName+".pdf")
- if os.path.exists(Output_pdf) : os.remove(Output_pdf)
- arcpy.mapping.ExportToPDF(CurrentMXD,Output_pdf)
- #Make layer invisible again
- Layer.visible = False
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement