<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: How to switch the active map in ArcGIS Pro project in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/how-to-switch-the-active-map-in-arcgis-pro-project/m-p/1245759#M66418</link>
    <description>&lt;P&gt;Excellent!&lt;/P&gt;&lt;P&gt;I used your solution and found it to work for my needs in this case.&lt;/P&gt;&lt;P&gt;Thank you.&lt;/P&gt;</description>
    <pubDate>Thu, 05 Jan 2023 19:12:03 GMT</pubDate>
    <dc:creator>BarakGarty</dc:creator>
    <dc:date>2023-01-05T19:12:03Z</dc:date>
    <item>
      <title>How to switch the active map in ArcGIS Pro project</title>
      <link>https://community.esri.com/t5/python-questions/how-to-switch-the-active-map-in-arcgis-pro-project/m-p/1245649#M66408</link>
      <description>&lt;P&gt;I have 2 Maps (tabs) in an active (loaded) project in the AcrGIS Pro SW.&lt;/P&gt;&lt;P&gt;Map1 is the active map. I am running a script via the python console&amp;nbsp; that intersect 2 layers (lyr1 and lyr2) that are in Map2 and output a new layer (lyr3);&lt;/P&gt;&lt;P&gt;The output of that intersect operation is added to the active Map (Map1) but I want it to be added to where the 2 layers that are being intersect are (i.e. Map2);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;- I know that I can manually switch the active map by selecting it with the mouse prior to running my script. Don't want to do it this way....&lt;/P&gt;&lt;P&gt;- Is there a python method to force that switch? I tried using openView() but this is not the solution I am looking for as this opens another view of Map2 that already exists.&amp;nbsp;&lt;/P&gt;&lt;P&gt;* this same question was asked in this forum last May but was not answered.&lt;/P&gt;&lt;P&gt;Thanks in advance.&lt;/P&gt;</description>
      <pubDate>Thu, 05 Jan 2023 16:34:29 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-to-switch-the-active-map-in-arcgis-pro-project/m-p/1245649#M66408</guid>
      <dc:creator>BarakGarty</dc:creator>
      <dc:date>2023-01-05T16:34:29Z</dc:date>
    </item>
    <item>
      <title>Re: How to switch the active map in ArcGIS Pro project</title>
      <link>https://community.esri.com/t5/python-questions/how-to-switch-the-active-map-in-arcgis-pro-project/m-p/1245679#M66412</link>
      <description>&lt;P&gt;When I ran into this issue, I set the environmental variable addOutputsToMap to false. This of course only works if you are running your code in Pro, which it sounds like you are.&lt;/P&gt;&lt;LI-CODE lang="c"&gt;arc.env.addOutputstoMap = False&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;That stops layers from being automatically added to maps. Then, if you store the result of your intersect in a variable, you can use addDataFromPath on the specific map you want to add the layer to.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Relevant links:&lt;/P&gt;&lt;P&gt;&lt;A href="https://pro.arcgis.com/en/pro-app/latest/arcpy/classes/env.htm" target="_blank"&gt;env—ArcGIS Pro | Documentation&lt;/A&gt;&amp;nbsp;(search addOutputstoMap&lt;/P&gt;&lt;P&gt;&lt;A href="https://pro.arcgis.com/en/pro-app/latest/arcpy/mapping/map-class.htm" target="_blank"&gt;Map—ArcGIS Pro | Documentation&lt;/A&gt;&amp;nbsp;(search addDataFromPath)&lt;/P&gt;</description>
      <pubDate>Thu, 05 Jan 2023 17:13:41 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-to-switch-the-active-map-in-arcgis-pro-project/m-p/1245679#M66412</guid>
      <dc:creator>DanielMiranda2</dc:creator>
      <dc:date>2023-01-05T17:13:41Z</dc:date>
    </item>
    <item>
      <title>Re: How to switch the active map in ArcGIS Pro project</title>
      <link>https://community.esri.com/t5/python-questions/how-to-switch-the-active-map-in-arcgis-pro-project/m-p/1245680#M66413</link>
      <description>&lt;P&gt;It sounds like you want to specifically check if a map is open as a View and then work with it if it is open and if it is not open, you want to open it and then specifically add layers to a certain map correct?&lt;/P&gt;&lt;P&gt;There's a post &lt;A href="https://community.esri.com/t5/python-questions/listing-open-maps-only-in-an-arcgis-pro-project/td-p/1118592" target="_blank" rel="noopener"&gt;here&lt;/A&gt; where it indicates that there's not a way to tell if a map is open in a view and an ESRI employee suggests that it would be good to submit an idea that exposes that property of a map.&lt;/P&gt;&lt;P&gt;However, despite knowing whether or not the view is open, explicitly getting a reference to each map using the &lt;A href="https://pro.arcgis.com/en/pro-app/latest/arcpy/mapping/arcgisproject-class.htm" target="_blank" rel="noopener"&gt;aprx object&lt;/A&gt; that you want to interact with is totally possible and might meet your need.&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;aprx = arcpy.mp.ArcGISProject("CURRENT")
map1 = aprx.listMaps("my first map")
if map1 == None:
    print("Could not find map: my first map")
    # end or raise error here

map2 = aprx.listMaps("my second map")
if map2 == None:
    print("Could not find map: my second map")
    # end or raise error here
&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Each &lt;A href="https://pro.arcgis.com/en/pro-app/latest/arcpy/mapping/map-class.htm" target="_blank" rel="noopener"&gt;map object&lt;/A&gt; could then be used to add layers as you wish.&lt;/P&gt;</description>
      <pubDate>Thu, 05 Jan 2023 17:14:00 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-to-switch-the-active-map-in-arcgis-pro-project/m-p/1245680#M66413</guid>
      <dc:creator>DougGreen</dc:creator>
      <dc:date>2023-01-05T17:14:00Z</dc:date>
    </item>
    <item>
      <title>Re: How to switch the active map in ArcGIS Pro project</title>
      <link>https://community.esri.com/t5/python-questions/how-to-switch-the-active-map-in-arcgis-pro-project/m-p/1245759#M66418</link>
      <description>&lt;P&gt;Excellent!&lt;/P&gt;&lt;P&gt;I used your solution and found it to work for my needs in this case.&lt;/P&gt;&lt;P&gt;Thank you.&lt;/P&gt;</description>
      <pubDate>Thu, 05 Jan 2023 19:12:03 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-to-switch-the-active-map-in-arcgis-pro-project/m-p/1245759#M66418</guid>
      <dc:creator>BarakGarty</dc:creator>
      <dc:date>2023-01-05T19:12:03Z</dc:date>
    </item>
  </channel>
</rss>

