How to get the selected layers in the TOC (i.e. clicked via the mouse and is now highlighted) with arcpy? thank you.
there is no arcpy functionality to do this
You could check them (uncheck the others you don't want) and then use the lyr.visible property to separate them.
aprx = arcpy.mp.ArcGISProject(r'C:\.aprx') m = aprx.listMaps("Map")[0] checked_layers = [lyr for lyr in m.listLayers() if lyr.visible] #for lyr in m.listLayers(): # if lyr.visible: # arcpy.AddMessage(f"{lyr.name} is selected.")
Signed in members can post, follow updates, and more. New here? Register a free account.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.