I'm running ArcGIS 10.3.1. and desire to list layers in the current mxd. I'm using the "CURRENT" method...
arcpy.mapping.MapDocument("CURRENT")
...within a python script tool, accessed via a single ArcMap session with the environment setting set to foreground processing. The usage is correct (identical to the help) and has worked for me last year. why would a foreground process fail to find the single mxd that it's being run from?
Link Esri ArcGIS 10.3 Help: Map Documents
import arcpy
mxd = arcpy.mapping.MapDocument("CURRENT")
for lyr in arcpy.mapping.ListLayers(mxd):
arcpy.AddMessage(lyr.name)
del mxd
arcpy.AddMessage(" ... current mxd ")
{}
button. However, can you also remove thetry/except
block from any code presented here because that masks the errors that Python provides to help you and us debug.