A simple yet powerful method in ArcPy is missing: opening/activating an existing map.
It is possible to add a new map (newMap = aprx.createMap("Map")) and it is also possible to get the (last) active maps (aprx = arcpy.mp.ArcGISProject("current") //active_map = aprx.activeMap).
What's missing is a method to not only replace the "activeMap" in the code, but also to open/activate that map, so that it is displayed in the map view window. To activate a map in the code it would need a method like "Mapname.activate()" which overwrites the previous"activeMap". Since normally the active map is the last used map in the map view window (the big part in the middle of the screen), the anticipated method "activate()" would also need to add that activated map.
I could think of many cases where this method could be used.
@nadja Have you tried:
Map.openView()? It opens a view for the map objects AND activates it. This works for Layout and Reports too.
We also have ArcGISProject.closeViews()
Jeff - Layout and arcpy.mp teams
@JeffBarrette no - thank you, that's exactly what I meant 🙂 I leave the idea, in case anyone else has trouble finding the documentation...
@Pukawai The original author of this idea was happy with the solution so we marked it accordingly. We also have ArcGISProject.closeViews() so you can close your views, then open the specific view using openView(). OpenView will automatically activate the view.
We have NO way of referencing existing views because individual instances are not uniquely named. Closing views and (re)opening ensures you get the active view you want.
At 3.7 we enhanced closeViews() to include a wildcard parameter so rather than closing all map views, for example, you can close views that only reference a specific map. See: arcpy.mp Map and Layout isOpen - Esri Community
The major focus of arcpy.mp is for ArcGIS Project automation, not application development. There are many scenarios where the .Net SDK is a better solution for application development.
I hope this helps,
Jeff - arcpy.mp team
Thank you, Jeff.
If closeViews() has that parameter, then that would be a workaround. Will just have to wait a couple months for it. I understand that the .net SDK is better for this kind of development as it was for ArcMap, but with Pro there's a such huge difference in the amount of time and effort require to get something workin, especially if it needs some sort of UI pane, so simple things like this and getting a list of selected layers in TOC seen high priority.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.