Need help printing only selected features in a layer, currently have the following:
import arcpy
#Set variables
arcpy.mp.ArcGISProject('CURRENT')
aprx = arcpy.mp.ArcGISProject('CURRENT')
TCG4232_USNG_GRIDS = "P:/PROJECTS/RP_Quality_Control_cGIS/MapSalesArcProProject/MapSalesLive1211/MapSalesLive/Data/GRIDS/USNG_GRID_OH.gdb"
Output_Folder = arcpy.GetParameterAsText(0)
#list of layer names that you want to be turned off.
p = arcpy.mp.ArcGISProject("Current")
m = p.listMaps("Map")[0]
layer_names = ['TCG4232_USNG_GRIDS']
lyrList = m.listLayers()
for lyr in lyrList:
lyr.visible = True
if lyr.name in layer_names:
lyr.visible = False
#Print to PDF
try:
aprx = arcpy.mp.ArcGISProject('CURRENT')
l = aprx.listLayouts()[0]
l.mapSeries.refresh()
if l.mapSeries is not None:
ms = l.mapSeries
if ms.enabled:
ms = l.mapSeries
indexLyr = "TCG4232_USNG_GRIDS"
ms.exportToPDF(Output_Folder,"SELECTED",
"",
"PDF_SINGLE_FILE",
150,
"FASTEST",
True,
"ADAPTIVE",
True,
"LAYERS_ONLY",
True,
80,
True,
False)
except Exception as e:
print(f"Error: {e.args[0]}")