Select to view content in your preferred language

Switching between layouts

134
1
12-06-2024 08:12 AM
TonyAlmeida
MVP Regular Contributor

I have a script that works with multiple maps and layouts in ArcGIS Pro: Map1 is associated with Layout1, Map2 with Layout2, and Map3 with Layout3. My script includes several functions, and specific functions need to be executed on specific maps and layouts.

One of the operations in the script uses arcpy.SelectLayerByLocation_management. I encounter an error stating that a layer does not exist. This happens because the target map or layout is not active when the function is executed.

Is there a way in Python to programmatically switch between maps and layouts to ensure the operations run on the correct context, even if the map or layout isn't currently active in the ArcGIS Pro interface?

0 Kudos
1 Reply
DanPatterson
MVP Esteemed Contributor

If you know the names apriori, then you could use listMaps or listLayouts with the name as a filter prior to seletlayerbylocation

ArcGISProject—ArcGIS Pro | Documentation

or you could use the memory workspace for the processing and save the results if needed

Write geoprocessing output to memory—ArcGIS Pro | Documentation


... sort of retired...
0 Kudos