Exporting to PDF: Multiple feature classes with common values as separate PDFs

05-23-2020 09:07 AM
New Contributor

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:

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.mapping.ExportToPDF(m, PDFPath + "\\" + lyr.name + ".PDF")
lyr.visible = False

del m

0 Kudos
1 Reply
MVP Esteemed Contributor


would provide line numbers and enable easier syntax checking

... sort of retired...
0 Kudos