<?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 Change active map with python in current project in ArcGIS Pro Questions</title>
    <link>https://community.esri.com/t5/arcgis-pro-questions/change-active-map-with-python-in-current-project/m-p/1173927#M55164</link>
    <description>&lt;P&gt;ArcGIS Pro 2.9.2 on Dell laptop running Windows 10.&lt;/P&gt;&lt;P&gt;I have a project opened and I want to use Python to change the active map.&amp;nbsp;&lt;/P&gt;&lt;P&gt;For this example, I have two maps in my ArcGISProject. Currently "Map A" is my active map, but when I run some geoprocessing tools, via python window, the output will be added to "Map A", but I want the output to be added to "B Map".&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can I switch my active map with Python? Or how do I direct the output to a specific map? The arcpy.env does not seem to cover "maps".&lt;/P&gt;&lt;P&gt;import arcpy&lt;/P&gt;&lt;P&gt;aprx = arcpy.mp.ArcGISProject('current')&lt;BR /&gt;map1 = aprx.listMaps("Map A")[0]&lt;BR /&gt;map2 = aprx.listMaps("B Map")[0]&lt;/P&gt;&lt;P&gt;Thanks for you help.&lt;/P&gt;&lt;P&gt;-John&lt;/P&gt;</description>
    <pubDate>Fri, 13 May 2022 20:38:14 GMT</pubDate>
    <dc:creator>JohnFixCai</dc:creator>
    <dc:date>2022-05-13T20:38:14Z</dc:date>
    <item>
      <title>Change active map with python in current project</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/change-active-map-with-python-in-current-project/m-p/1173927#M55164</link>
      <description>&lt;P&gt;ArcGIS Pro 2.9.2 on Dell laptop running Windows 10.&lt;/P&gt;&lt;P&gt;I have a project opened and I want to use Python to change the active map.&amp;nbsp;&lt;/P&gt;&lt;P&gt;For this example, I have two maps in my ArcGISProject. Currently "Map A" is my active map, but when I run some geoprocessing tools, via python window, the output will be added to "Map A", but I want the output to be added to "B Map".&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can I switch my active map with Python? Or how do I direct the output to a specific map? The arcpy.env does not seem to cover "maps".&lt;/P&gt;&lt;P&gt;import arcpy&lt;/P&gt;&lt;P&gt;aprx = arcpy.mp.ArcGISProject('current')&lt;BR /&gt;map1 = aprx.listMaps("Map A")[0]&lt;BR /&gt;map2 = aprx.listMaps("B Map")[0]&lt;/P&gt;&lt;P&gt;Thanks for you help.&lt;/P&gt;&lt;P&gt;-John&lt;/P&gt;</description>
      <pubDate>Fri, 13 May 2022 20:38:14 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/change-active-map-with-python-in-current-project/m-p/1173927#M55164</guid>
      <dc:creator>JohnFixCai</dc:creator>
      <dc:date>2022-05-13T20:38:14Z</dc:date>
    </item>
    <item>
      <title>Re: Change active map with python in current project</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/change-active-map-with-python-in-current-project/m-p/1173974#M55167</link>
      <description>&lt;P&gt;Is the project open and you are using a notebook or the python window?&lt;/P&gt;&lt;P&gt;tool in arctoolbox&lt;/P&gt;&lt;P&gt;What circumstances would you need to add data to a map that isn't open instead of the one that is?&lt;/P&gt;</description>
      <pubDate>Sat, 14 May 2022 01:10:33 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/change-active-map-with-python-in-current-project/m-p/1173974#M55167</guid>
      <dc:creator>DanPatterson</dc:creator>
      <dc:date>2022-05-14T01:10:33Z</dc:date>
    </item>
    <item>
      <title>Re: Change active map with python in current project</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/change-active-map-with-python-in-current-project/m-p/1174126#M55187</link>
      <description>The project is open, and I am using the Python window.&lt;BR /&gt;Use case: In one map I generate a vector tile cache, in another map I process layers and tables for geocoding, routing and other purposes, and in a third map I add the vector tile package, routing network, and other layers and tables from "map2" and output a mobile map package.&lt;BR /&gt;Currently I have my scripts divided into 7 "steps" and I manually switch between windows and run the steps. Ideally, I'd like a single script to run the entire process.&lt;BR /&gt;I do understand the create vector tile cache and create mobile map package take the map name as an argument, so in theory I could have "map 2" as my active map. However, there is one function that is not exposed in python I must do manually in the vector tile cache "map" before running the create vector tile cache processing. And, I am still learning python to get the AOI layer at the bottom of the layer stack to create the mobile map package, or the extent of the mmpk is incorrect.&lt;BR /&gt;Thanks!&lt;BR /&gt;</description>
      <pubDate>Mon, 16 May 2022 11:29:33 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/change-active-map-with-python-in-current-project/m-p/1174126#M55187</guid>
      <dc:creator>JohnFixCai</dc:creator>
      <dc:date>2022-05-16T11:29:33Z</dc:date>
    </item>
    <item>
      <title>Re: Change active map with python in current project</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/change-active-map-with-python-in-current-project/m-p/1277984#M67902</link>
      <description>&lt;P&gt;Did you ever figure out how to achieve the switch?&lt;/P&gt;&lt;P&gt;I also got stuck trying to do this with arcpy, currently looking into what SDK has to offer for this use case.&lt;/P&gt;</description>
      <pubDate>Wed, 12 Apr 2023 20:00:43 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/change-active-map-with-python-in-current-project/m-p/1277984#M67902</guid>
      <dc:creator>cs-map</dc:creator>
      <dc:date>2023-04-12T20:00:43Z</dc:date>
    </item>
    <item>
      <title>Re: Change active map with python in current project</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/change-active-map-with-python-in-current-project/m-p/1278194#M67919</link>
      <description>&lt;P&gt;within the script I can target which map I add/remove/modify layers. This has help streamline the process. But I still have 3 scripts instead of 7. I still get tripped up in 2 places....&lt;/P&gt;&lt;P&gt;When I am processing layers and I want to add them to the map to output a mobile map package, I can specify the map to add the layers, and then I can turn them off as I don't want them visible, but usable by the app.&lt;/P&gt;&lt;P&gt;# --- gets the current ArcGIS Pro project file&lt;/P&gt;&lt;P&gt;aprx = arcpy.mp.ArcGISProject("CURRENT")&lt;/P&gt;&lt;P&gt;# --- gets the target map&lt;/P&gt;&lt;P&gt;m = aprx.listMaps("MMPK Output*")[0]&lt;/P&gt;&lt;P&gt;# --- sets the path and layers to add&lt;/P&gt;&lt;P&gt;LayerPath = ("D:\\Mobile Map Package Creator\\map_data.gdb\\")&lt;/P&gt;&lt;P&gt;LayerList = ("COMPLEXES", "MILEMARKERS", "Zones", "ROAD_NAMES")&lt;/P&gt;&lt;P&gt;# --- loops thru the layers and adds them to the target map, and then turns the visibility off&lt;/P&gt;&lt;P&gt;for Layer in LayerList:&lt;BR /&gt;AddStatus = m.addDataFromPath(LayerPath + Layer)&lt;BR /&gt;LayerName = m.listLayers(Layer)[0]&lt;BR /&gt;VisibleState = LayerName.visible = 0 #turn off layer&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What trips me up?&lt;/P&gt;&lt;P&gt;The extent needs to be entered as a property of the map to create a vector tile cache, I can't find a way to do that in python.&lt;/P&gt;&lt;P&gt;I can't seem to use the above python to add a Network Dataset to the map.&lt;/P&gt;</description>
      <pubDate>Thu, 13 Apr 2023 12:13:57 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/change-active-map-with-python-in-current-project/m-p/1278194#M67919</guid>
      <dc:creator>JohnFixCai</dc:creator>
      <dc:date>2023-04-13T12:13:57Z</dc:date>
    </item>
  </channel>
</rss>

