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]}")
the lyr.visible turns the layer on/off only (either view all or none).
If you want to just display a subset of the data in a layer, you would put a definition query on the layer and have that layer as visible = True.
R_
I Intended to turn off the layer, my print needs the layer off but I still need the region of the layer area to print.
I just need my print to target the "TCG4232_Grids" layer.