Select to view content in your preferred language

Saving active view into ArcGIS Pro project using ArcPy

3154
5
06-17-2017 02:07 AM
Status: Implemented
Labels (1)
GraemeBrowning
Frequent Contributor

I have a desirable requirement to be able to set the active view (Layout, Map, Basemap, etc) in an ArcGIS Pro project using ArcPy.

However the ArcGISProject class does not seem to provide a method to do this.

I would like to be able to make sure that a particular Layout in my ArcGIS Pro project is the view that a copy of my project (made using the saveACopy method) opens to when I give it to someone.

If I were using ArcPy with ArcMap the equivalent would be accessible in the activeView property of the MapDocument class.

5 Comments
JeffBarrette

Thank you for your feedback!  This is a very difficult equivalency feature.  We do not have a solution for this yet but would really like to understand your requirements better so that we might be able to provide some level of support.

Views in Pro are much different than data frames in ArcMap.  In ArcMap you always had at least a single data frame (and always 1 layout).  In Pro, you can have 0-many layouts and they may or may not have map frames.

Also with Pro, you can create multiple views of the same project item (e.g., 3 views of the same map or layout and potentially the same camera info, or not).  There is not a way to distinguish one view from another - i.e., no unique naming. So with arcpy.mp you can easily reference a map or layout and manipulate them but here is no way to isolate a specific view of a map (or layout). 

We did recently add Project.ActiveMap so that if you have a script tool you can reference the active map but you can't set it for reasons stated above.

Again, please provide some scenarios so we can better understand what you are trying to do.

Thanks,

Jeff

GraemeBrowning

Thanks for looking into this Jeff

It is a requirement that comes out of a large automated mapping application that I wrote for a large government mapmaker.

The application produces PDFs of standard maps at 3 scales and for ad hoc extents at 7 scales.

It supports 4 projected coordinate systems and dynamic tables.

To achieve this it has a map for each projected coordinate system, another for a geographic coordinate system, two more for overview and index maps, plus another used for the dynamic tables.

Whenever the application is run, which happens via a Python script tool with many options, one option is to save a copy of the project in the state that it was immediately prior to the ExportToPDF on its Layout.

The reason an operator may do this, which they frequently do, is to be able to open that copy of the project and then do some manual touch ups in ArcGIS Pro before re-exporting to PDF as a final map.  They are cartographers so it is impossible to write code for all their possible ad hoc requirements.

This works reasonably well, but a cartographer may be thrown if the last time the master project was saved, the project was open to one of the maps when they normally work with the Layout.

I'm really just wanting to be able to use ArcPy to set which view from Layout, Map1, Map2, Map3, etc the saved copy of the project will open to when they double-click the <copy>.aprx.

GeoNZ
by

I also have this requirement for similar reasons- A script/tool is used to generate a  consistent map document from a template when given a centerpoint coordinate, scale, page size + orientation, title etc. In Arcmap, templates mxds were created for each page size/orientation and scale, the script would open the relevant one, pan to location, update some text elements then save a copy in the output folder. If the map wasn't in layout view, it would warn or switch.

In Pro, all sizes/orientation (A4P, A4L --- A0P, A0L) layouts are contained within a single aprx (which is really useful for managing them!). The update Pro script does a similar thing although there is no way to

a) set the active layout to what size/orientation the user has chosen and/or

b) delete the other size/orientations from the savedAs aprx.

Each Layout in the aprx has a unique name (in this case, the name of the size/orientation and scale, i.e. A4P_50K) so could be referenced by that name from a listLayouts etc. Each layout references the same 2 maps (a main map and an inset).

KoryKramer
Status changed to: Implemented

This functionality has been added in ArcGIS Pro 3.0. See Ideas in ArcGIS Pro 3.0  to see this and all of the other ideas you can look forward to when you upgrade.

Also be sure to check out the What's New documentation: https://pro.arcgis.com/en/pro-app/latest/get-started/whats-new-in-arcgis-pro.htm  

PhilLarkin1

This doesn't quite target your use case, but I found it helpful when trying to set the active map in a project. If a script is run via a Task the Views setting can be applied to Activate a map and close others. This was super helpful for me. Ideally this could also be achieved in ArcPy as well.

PhilLarkin1_1-1660668025577.png