[GIS] Finding current map in ArcGIS Pro Project using ArcPy

arcgis-proarcpy

I try to do the following in ArcGIS Pro with ArcPy:
I want to select the current map in a project, in which the user is currently working.

So far I have just one map so I can do it like this:

aprx = arcpy.mp.ArcGISProject("CURRENT")
s = aprx.listMaps("Scene")[0]
layerList = s.listLayers()

And then I do something with the selected features…

Now I have multiple maps and I don't want to iterrate through all layers in all maps. Is there some way to do something like this:

s = aprx.currentMap()

Or to test if the Map is the current one?

Best Answer

It felt like I spent about 6-8 hours trying to figure this out and it turns out its quite simple facepalm. Its mentioned at the top of the ArcGIS Project class page here:

http://pro.arcgis.com/en/pro-app/arcpy/mapping/arcgisproject-class.htm

Code I used to get the active map name was this:

aprx = arcpy.mp.ArcGISProject('CURRENT')
print(aprx.activeMap.name)

So in short I believe what you're looking for is: activeMap