<?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: get active map from ArcGIS Pro project in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/get-active-map-from-arcgis-pro-project/m-p/1504435#M71060</link>
    <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;import arcpy

# Get the current project
aprx = arcpy.mp.ArcGISProject("CURRENT")

# Get the active map
map = aprx.activeMap

# Print active map.

print("Active Map:", map.name) &lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;or&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;import arcpy

# Get the current project
aprx = arcpy.mp.ArcGISProject("CURRENT")

# Get the active map
active_map = aprx.listMaps(aprx.activeMap.name)[0]

# print active map.
print("Active Map:", active_map.name)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 11 Jul 2024 19:48:53 GMT</pubDate>
    <dc:creator>TonyAlmeida</dc:creator>
    <dc:date>2024-07-11T19:48:53Z</dc:date>
    <item>
      <title>get active map from ArcGIS Pro project</title>
      <link>https://community.esri.com/t5/python-questions/get-active-map-from-arcgis-pro-project/m-p/1504225#M71054</link>
      <description>&lt;P&gt;Acually, I found various posts to how to get the active map of the current ArcGIS Pro project. they all start with this:&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;aprx = arcpy.mp.ArcGISProject("CURRENT")
active_map = aprx.listMaps(aprx.activeMap.name)[0]&lt;/LI-CODE&gt;&lt;P&gt;I always get the exception "CURRENT". I already tried "current", then I get the exception "current". any idea whats wrong or how to make it right?&lt;/P&gt;</description>
      <pubDate>Thu, 11 Jul 2024 15:28:46 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/get-active-map-from-arcgis-pro-project/m-p/1504225#M71054</guid>
      <dc:creator>nadja</dc:creator>
      <dc:date>2024-07-11T15:28:46Z</dc:date>
    </item>
    <item>
      <title>Re: get active map from ArcGIS Pro project</title>
      <link>https://community.esri.com/t5/python-questions/get-active-map-from-arcgis-pro-project/m-p/1504233#M71055</link>
      <description>&lt;P&gt;See example 2, it needs to be run from an open project within Pro&lt;/P&gt;&lt;P&gt;&lt;A href="https://pro.arcgis.com/en/pro-app/latest/arcpy/mapping/arcgisproject-class.htm" target="_blank" rel="noopener"&gt;ArcGISProject—ArcGIS Pro | Documentation&lt;/A&gt;&lt;/P&gt;&lt;P&gt;otherwise specify the project's full pathname&lt;/P&gt;&lt;P&gt;also don't forget&lt;/P&gt;&lt;P&gt;import arcpy&lt;/P&gt;</description>
      <pubDate>Thu, 11 Jul 2024 15:43:39 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/get-active-map-from-arcgis-pro-project/m-p/1504233#M71055</guid>
      <dc:creator>DanPatterson</dc:creator>
      <dc:date>2024-07-11T15:43:39Z</dc:date>
    </item>
    <item>
      <title>Re: get active map from ArcGIS Pro project</title>
      <link>https://community.esri.com/t5/python-questions/get-active-map-from-arcgis-pro-project/m-p/1504290#M71057</link>
      <description>&lt;P&gt;The second line is actually redundant as the activeMap parameter returns a map object, and the listMaps(name)[0] is just getting the same map object you're feeding into it.&lt;/P&gt;</description>
      <pubDate>Thu, 11 Jul 2024 16:28:47 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/get-active-map-from-arcgis-pro-project/m-p/1504290#M71057</guid>
      <dc:creator>HaydenWelch</dc:creator>
      <dc:date>2024-07-11T16:28:47Z</dc:date>
    </item>
    <item>
      <title>Re: get active map from ArcGIS Pro project</title>
      <link>https://community.esri.com/t5/python-questions/get-active-map-from-arcgis-pro-project/m-p/1504435#M71060</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;import arcpy

# Get the current project
aprx = arcpy.mp.ArcGISProject("CURRENT")

# Get the active map
map = aprx.activeMap

# Print active map.

print("Active Map:", map.name) &lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;or&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;import arcpy

# Get the current project
aprx = arcpy.mp.ArcGISProject("CURRENT")

# Get the active map
active_map = aprx.listMaps(aprx.activeMap.name)[0]

# print active map.
print("Active Map:", active_map.name)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 11 Jul 2024 19:48:53 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/get-active-map-from-arcgis-pro-project/m-p/1504435#M71060</guid>
      <dc:creator>TonyAlmeida</dc:creator>
      <dc:date>2024-07-11T19:48:53Z</dc:date>
    </item>
    <item>
      <title>Re: get active map from ArcGIS Pro project</title>
      <link>https://community.esri.com/t5/python-questions/get-active-map-from-arcgis-pro-project/m-p/1504595#M71061</link>
      <description>&lt;P&gt;Be careful overwriting builtins like 'map' with variable names, this can have unintended side effects if you have a long script and forget you did it.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If you absolutely have to use a built-in, try and mask it as an instance parameter so it's shielded by "self."/"instance." or if you need it in a larger scope, prefix it with an '_' ("_map")&lt;/P&gt;</description>
      <pubDate>Fri, 12 Jul 2024 02:46:02 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/get-active-map-from-arcgis-pro-project/m-p/1504595#M71061</guid>
      <dc:creator>HaydenWelch</dc:creator>
      <dc:date>2024-07-12T02:46:02Z</dc:date>
    </item>
    <item>
      <title>Re: get active map from ArcGIS Pro project</title>
      <link>https://community.esri.com/t5/python-questions/get-active-map-from-arcgis-pro-project/m-p/1505269#M71065</link>
      <description>&lt;P&gt;Hi,&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have "import arcpy" and I copy-pasted the second example, but I still get Exception: CURRENT. Any idea why?&lt;/P&gt;&lt;P&gt;what means "sort of retired"?&lt;/P&gt;</description>
      <pubDate>Mon, 15 Jul 2024 08:02:51 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/get-active-map-from-arcgis-pro-project/m-p/1505269#M71065</guid>
      <dc:creator>nadja</dc:creator>
      <dc:date>2024-07-15T08:02:51Z</dc:date>
    </item>
    <item>
      <title>Re: get active map from ArcGIS Pro project</title>
      <link>https://community.esri.com/t5/python-questions/get-active-map-from-arcgis-pro-project/m-p/1505270#M71066</link>
      <description>&lt;P&gt;Thanks, but I still get the same error message &lt;span class="lia-unicode-emoji" title=":disappointed_face:"&gt;😞&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 15 Jul 2024 08:03:24 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/get-active-map-from-arcgis-pro-project/m-p/1505270#M71066</guid>
      <dc:creator>nadja</dc:creator>
      <dc:date>2024-07-15T08:03:24Z</dc:date>
    </item>
    <item>
      <title>Re: get active map from ArcGIS Pro project</title>
      <link>https://community.esri.com/t5/python-questions/get-active-map-from-arcgis-pro-project/m-p/1505271#M71067</link>
      <description>&lt;P&gt;if I understand you correctly, you would recommend the second line to be this:&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;map = aprx.listMaps(aprx.activeMap.name)[0]&lt;/LI-CODE&gt;</description>
      <pubDate>Mon, 15 Jul 2024 08:04:30 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/get-active-map-from-arcgis-pro-project/m-p/1505271#M71067</guid>
      <dc:creator>nadja</dc:creator>
      <dc:date>2024-07-15T08:04:30Z</dc:date>
    </item>
    <item>
      <title>Re: get active map from ArcGIS Pro project</title>
      <link>https://community.esri.com/t5/python-questions/get-active-map-from-arcgis-pro-project/m-p/1505635#M71072</link>
      <description>&lt;P&gt;You can simplify that by just saying:&lt;/P&gt;&lt;P&gt;_map = aprx.activeMap&lt;/P&gt;&lt;P&gt;As the activeMap attribute of an ArcGISProject object is a Map object (same as what's returned by listMaps)&lt;/P&gt;&lt;P&gt;If you keep getting the error, it means your project either doesn't have an active map, or your project is not open ("CURRENT" only works with *open* project files). If you need to do this on projects that are closed, you'll need to replace "CURRENT" with a full path to the .aprx file and replace .activeMap with either .listMaps()[0] for the first map in the project file (by order in contents). Or .listMaps('&amp;lt;mapName&amp;gt;')[0] for the first map that matches the '&amp;lt;mapName&amp;gt;' string.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Note: I prefixed your map variable with '_' for the reasons stated in my above comment. Shadowing builtin functions can have unintended side effects if you're doing it in the wrong scope. If you were to call 'map()' now it would raise a 'arcgis.Map object not Callable' error.&lt;/P&gt;</description>
      <pubDate>Tue, 16 Jul 2024 00:29:03 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/get-active-map-from-arcgis-pro-project/m-p/1505635#M71072</guid>
      <dc:creator>HaydenWelch</dc:creator>
      <dc:date>2024-07-16T00:29:03Z</dc:date>
    </item>
    <item>
      <title>Re: get active map from ArcGIS Pro project</title>
      <link>https://community.esri.com/t5/python-questions/get-active-map-from-arcgis-pro-project/m-p/1505667#M71076</link>
      <description>&lt;P&gt;I always use&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;map1 = aprx.activeMap&lt;/LI-CODE&gt;&lt;P&gt;You should try to open a project using full path (of different aprx then the one you are open with), just for checking.&lt;/P&gt;&lt;P&gt;Are other arcpy command works?&lt;/P&gt;&lt;P&gt;Note that if you open a project by path you do not always have activeMap&lt;/P&gt;</description>
      <pubDate>Tue, 16 Jul 2024 05:12:57 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/get-active-map-from-arcgis-pro-project/m-p/1505667#M71076</guid>
      <dc:creator>mody_buchbinder</dc:creator>
      <dc:date>2024-07-16T05:12:57Z</dc:date>
    </item>
  </channel>
</rss>

