Hi, I have a list of feature classes used as facilities in network analysis to find out walking and cycling time. So for example, schools, hospitals, pharmacies etc. I therefore want to export a PDF with the schools plus the study area, hospitals plus the study area etc. as separate PDFs for each facility and associated analysis:
import arcpy
#Get the MXD
m = arcpy.mapping.MapDocument("CURRENT")
#Get the data frame
d = arcpy.mapping.ListDataFrames(m, "")[0]
#Get the layer list in the data frame
ls = arcpy.mapping.ListLayers(m, "", d)
#Set layer dictionary
layer_dict = {"layer_name" : ["turn_on_lyr_1", "turn_on_lyr_2"]}
#Get the folder you want to save your PDF files into
PDFPath = r'C:\Users\Charlie-x.Churchill\Documents\PyTrial'
#Create empty list
layerList = []
#add layer names to the list
for l in ls:
layerList.append(l.name)
for lyr in arcpy.mapping.ListLayers(m, '',d):
for lname in layerList:
if lname in layer_dict:
for lyr in layer_dict[layer_name]: lyr.visible = True
lyr.visible = True
arcpy.RefreshActiveView()
arcpy.mapping.ExportToPDF(m, PDFPath + "\\" + lyr.name + ".PDF")
lyr.visible = False
del m
/blogs/dan_patterson/2016/08/14/script-formatting
would provide line numbers and enable easier syntax checking