4

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?

3

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

1

I am not sure that the concept of a "current map" makes any sense when using ArcPy with ArcGIS Pro.

By "current map" you may mean the map which was active when your project was last saved but you will not always have an active map because when you last saved your project you may have had a layout active instead.

  • Yes you're right, the "current map" doesn't make sense in every case. In my case, I use the ArcPy-Script in a Toolbox where the user selects some features in a map or scene and then I change some attributes for the selected features. So it would be nice to know in which map the user is working so I only iterate through the layers of the current map and don't have to iterate through every layer in every map to find the selected features. – Daho Dec 8 '17 at 10:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.