<?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 How do I set the map in a layout mapframe with python in Arc Pro? in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/how-do-i-set-the-map-in-a-layout-mapframe-with/m-p/1198925#M65157</link>
    <description />
    <pubDate>Wed, 03 Aug 2022 14:08:33 GMT</pubDate>
    <dc:creator>Anonymous User</dc:creator>
    <dc:date>2022-08-03T14:08:33Z</dc:date>
    <item>
      <title>How do I set the map in a layout mapframe with python in Arc Pro?</title>
      <link>https://community.esri.com/t5/python-questions/how-do-i-set-the-map-in-a-layout-mapframe-with/m-p/1198925#M65157</link>
      <description />
      <pubDate>Wed, 03 Aug 2022 14:08:33 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-do-i-set-the-map-in-a-layout-mapframe-with/m-p/1198925#M65157</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2022-08-03T14:08:33Z</dc:date>
    </item>
    <item>
      <title>Re: How do I set the map in a layout mapframe with python in Arc Pro?</title>
      <link>https://community.esri.com/t5/python-questions/how-do-i-set-the-map-in-a-layout-mapframe-with/m-p/1198927#M65158</link>
      <description>&lt;P&gt;Even if it's the same text, it's a good practice to put your question in both the title &lt;EM&gt;and &lt;/EM&gt;body of your posts here.&lt;/P&gt;&lt;P&gt;What you're looking for is &lt;STRONG&gt;Camera.setExtent()&lt;/STRONG&gt;, which you can read up on here: &lt;A href="https://pro.arcgis.com/en/pro-app/latest/arcpy/mapping/camera-class.htm" target="_blank"&gt;https://pro.arcgis.com/en/pro-app/latest/arcpy/mapping/camera-class.htm&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 03 Aug 2022 14:15:04 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-do-i-set-the-map-in-a-layout-mapframe-with/m-p/1198927#M65158</guid>
      <dc:creator>jcarlson</dc:creator>
      <dc:date>2022-08-03T14:15:04Z</dc:date>
    </item>
    <item>
      <title>Re: How do I set the map in a layout mapframe with python in Arc Pro?</title>
      <link>https://community.esri.com/t5/python-questions/how-do-i-set-the-map-in-a-layout-mapframe-with/m-p/1198930#M65159</link>
      <description>&lt;P&gt;Hi Josh&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for pointer around etiquette.&lt;/P&gt;&lt;P&gt;I have an empty map frame in a layout that I want to set the map view in and then zoom to the extent of one of the layers. I can't seem to get off the ground with this one or find much help on the web. Any assistance would be appreciated. Seems like it a fairly simple standard thing to want to do?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Matt&lt;/P&gt;</description>
      <pubDate>Wed, 03 Aug 2022 14:25:52 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-do-i-set-the-map-in-a-layout-mapframe-with/m-p/1198930#M65159</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2022-08-03T14:25:52Z</dc:date>
    </item>
    <item>
      <title>Re: How do I set the map in a layout mapframe with python in Arc Pro?</title>
      <link>https://community.esri.com/t5/python-questions/how-do-i-set-the-map-in-a-layout-mapframe-with/m-p/1198933#M65161</link>
      <description>&lt;P&gt;I'd start with the &lt;A href="https://pro.arcgis.com/en/pro-app/latest/arcpy/mapping/introduction-to-arcpy-mp.htm" target="_blank"&gt;Introduction to arcpy.mp&lt;/A&gt; article. There are some linked tutorials that can walk you through some of the simpler procedures.&lt;/P&gt;&lt;P&gt;Basically, you'd use something like this:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;import arcpy
aprx = arcpy.mp.ArcGISProject('CURRENT')

# get your layout
lyt = aprx.listLayouts('Your Layout Name')[0]

# get the map frame
mf = lyt.listElements('MAPFRAME_ELEMENT', 'your map frame name')[0] # note that the name of the frame is NOT the name of the map

# get specific layer you want
lyr = mf.map.listLayers('Your Layer Name')[0]

# set frame extent to match layer
mf.camera.setExtent(mf.getLayerExtent(lyr))&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 03 Aug 2022 14:38:05 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-do-i-set-the-map-in-a-layout-mapframe-with/m-p/1198933#M65161</guid>
      <dc:creator>jcarlson</dc:creator>
      <dc:date>2022-08-03T14:38:05Z</dc:date>
    </item>
    <item>
      <title>Re: How do I set the map in a layout mapframe with python in Arc Pro?</title>
      <link>https://community.esri.com/t5/python-questions/how-do-i-set-the-map-in-a-layout-mapframe-with/m-p/1198942#M65163</link>
      <description>&lt;P&gt;Hi Josh&lt;/P&gt;&lt;P&gt;That is what I ran and I receive the following error:&lt;/P&gt;&lt;P&gt;RuntimeError Traceback (most recent call last)&lt;BR /&gt;In [74]:&lt;BR /&gt;Line 7: mf.camera.setExtent(mf.getLayerExtent(lyr))&lt;/P&gt;&lt;P&gt;File C:\Program Files\ArcGIS\Pro\Resources\ArcPy\arcpy\_mp.py, in getLayerExtent:&lt;BR /&gt;Line 2150: return convertArcObjectToPythonObject(self._arc_object.getLayerExtent(*gp_fixargs((layer, selection_only, symbolized_extent), True)))&lt;/P&gt;&lt;P&gt;RuntimeError:&lt;/P&gt;</description>
      <pubDate>Wed, 03 Aug 2022 14:50:20 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-do-i-set-the-map-in-a-layout-mapframe-with/m-p/1198942#M65163</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2022-08-03T14:50:20Z</dc:date>
    </item>
    <item>
      <title>Re: How do I set the map in a layout mapframe with python in Arc Pro?</title>
      <link>https://community.esri.com/t5/python-questions/how-do-i-set-the-map-in-a-layout-mapframe-with/m-p/1198952#M65166</link>
      <description>&lt;P&gt;Try running &lt;STRONG&gt;mf.getLayerExtent(lyr)&lt;/STRONG&gt; on its own line? Maybe explicitly state the optional parameters, too.&lt;/P&gt;&lt;PRE&gt;mf.getLayerExtent(lyr, False, False)&lt;/PRE&gt;</description>
      <pubDate>Wed, 03 Aug 2022 15:01:15 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-do-i-set-the-map-in-a-layout-mapframe-with/m-p/1198952#M65166</guid>
      <dc:creator>jcarlson</dc:creator>
      <dc:date>2022-08-03T15:01:15Z</dc:date>
    </item>
    <item>
      <title>Re: How do I set the map in a layout mapframe with python in Arc Pro?</title>
      <link>https://community.esri.com/t5/python-questions/how-do-i-set-the-map-in-a-layout-mapframe-with/m-p/1198966#M65169</link>
      <description>&lt;P&gt;RuntimeError Traceback (most recent call last)&lt;BR /&gt;In [88]:&lt;BR /&gt;Line 7: mf.getLayerExtent(lyr, False, False)&lt;/P&gt;&lt;P&gt;File C:\Program Files\ArcGIS\Pro\Resources\ArcPy\arcpy\_mp.py, in getLayerExtent:&lt;BR /&gt;Line 2150: return convertArcObjectToPythonObject(self._arc_object.getLayerExtent(*gp_fixargs((layer, selection_only, symbolized_extent), True)))&lt;/P&gt;&lt;P&gt;RuntimeError:&lt;/P&gt;</description>
      <pubDate>Wed, 03 Aug 2022 15:11:14 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-do-i-set-the-map-in-a-layout-mapframe-with/m-p/1198966#M65169</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2022-08-03T15:11:14Z</dc:date>
    </item>
    <item>
      <title>Re: How do I set the map in a layout mapframe with python in Arc Pro?</title>
      <link>https://community.esri.com/t5/python-questions/how-do-i-set-the-map-in-a-layout-mapframe-with/m-p/1198969#M65170</link>
      <description>&lt;P&gt;Double check the value of the variables, make sure the &lt;STRONG&gt;lyr&lt;/STRONG&gt;, &lt;STRONG&gt;lyt&lt;/STRONG&gt;, and &lt;STRONG&gt;mf&lt;/STRONG&gt; are the objects they're supposed to be.&lt;/P&gt;</description>
      <pubDate>Wed, 03 Aug 2022 15:20:26 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-do-i-set-the-map-in-a-layout-mapframe-with/m-p/1198969#M65170</guid>
      <dc:creator>jcarlson</dc:creator>
      <dc:date>2022-08-03T15:20:26Z</dc:date>
    </item>
    <item>
      <title>Re: How do I set the map in a layout mapframe with python in Arc Pro?</title>
      <link>https://community.esri.com/t5/python-questions/how-do-i-set-the-map-in-a-layout-mapframe-with/m-p/1198975#M65171</link>
      <description>&lt;P&gt;aprx = arcpy.mp.ArcGISProject("CURRENT")&lt;/P&gt;&lt;P&gt;m = aprx.listMaps("Map")[0]&lt;BR /&gt;lyt = aprx.listLayouts("Layout1")[0]&lt;BR /&gt;mf = lyt.listElements("MAPFRAME_ELEMENT", "Map Frame 1")[0]&lt;BR /&gt;lyr = m.listLayers("Osterley")[0]&lt;BR /&gt;mf.getLayerExtent(lyr,False, False)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;RuntimeError Traceback (most recent call last)&lt;BR /&gt;In [105]:&lt;BR /&gt;Line 7: mf.getLayerExtent(lyr,False, False)&lt;/P&gt;&lt;P&gt;File C:\Program Files\ArcGIS\Pro\Resources\ArcPy\arcpy\_mp.py, in getLayerExtent:&lt;BR /&gt;Line 2150: return convertArcObjectToPythonObject(self._arc_object.getLayerExtent(*gp_fixargs((layer, selection_only, symbolized_extent), True)))&lt;/P&gt;&lt;P&gt;RuntimeError:&lt;BR /&gt;---------------&lt;/P&gt;</description>
      <pubDate>Wed, 03 Aug 2022 15:31:58 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-do-i-set-the-map-in-a-layout-mapframe-with/m-p/1198975#M65171</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2022-08-03T15:31:58Z</dc:date>
    </item>
    <item>
      <title>Re: How do I set the map in a layout mapframe with python in Arc Pro?</title>
      <link>https://community.esri.com/t5/python-questions/how-do-i-set-the-map-in-a-layout-mapframe-with/m-p/1198977#M65172</link>
      <description>&lt;P&gt;I mean try running a cell that's just "m" and see what is returned, make sure they're actually layouts, layers, etc.&lt;/P&gt;</description>
      <pubDate>Wed, 03 Aug 2022 15:39:53 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-do-i-set-the-map-in-a-layout-mapframe-with/m-p/1198977#M65172</guid>
      <dc:creator>jcarlson</dc:creator>
      <dc:date>2022-08-03T15:39:53Z</dc:date>
    </item>
    <item>
      <title>Re: How do I set the map in a layout mapframe with python in Arc Pro?</title>
      <link>https://community.esri.com/t5/python-questions/how-do-i-set-the-map-in-a-layout-mapframe-with/m-p/1198980#M65173</link>
      <description>&lt;P&gt;Hi Josh&lt;/P&gt;&lt;P&gt;All the objects are correct and if I run the script without the last line it doesn't return an error.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Not sure what else to try, which is a shame! I will keep searching for a solution.&lt;/P&gt;</description>
      <pubDate>Wed, 03 Aug 2022 15:43:35 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-do-i-set-the-map-in-a-layout-mapframe-with/m-p/1198980#M65173</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2022-08-03T15:43:35Z</dc:date>
    </item>
    <item>
      <title>Re: How do I set the map in a layout mapframe with python in Arc Pro?</title>
      <link>https://community.esri.com/t5/python-questions/how-do-i-set-the-map-in-a-layout-mapframe-with/m-p/1199307#M65197</link>
      <description>&lt;P&gt;I'm not sure if you interested but the below works in terms of setting the extent if you manually select the map you want for the mapframe first:&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;aprx = arcpy.mp.ArcGISProject("CURRENT")&lt;/P&gt;&lt;P&gt;m = aprx.listMaps("Osterley_Boundary")[0]&lt;BR /&gt;lyr = m.listLayers("Osterley")[0]&lt;BR /&gt;lyt = aprx.listLayouts("Property_Boundary")[0]&lt;BR /&gt;mf = lyt.listElements("MAPFRAME_ELEMENT", "Map Frame 1")[0]&lt;BR /&gt;mf.camera.setExtent(mf.getLayerExtent(lyr, False, True))&lt;/P&gt;</description>
      <pubDate>Thu, 04 Aug 2022 09:14:02 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-do-i-set-the-map-in-a-layout-mapframe-with/m-p/1199307#M65197</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2022-08-04T09:14:02Z</dc:date>
    </item>
    <item>
      <title>Re: How do I set the map in a layout mapframe with python in Arc Pro?</title>
      <link>https://community.esri.com/t5/python-questions/how-do-i-set-the-map-in-a-layout-mapframe-with/m-p/1358556#M69364</link>
      <description>&lt;P&gt;Is it possible to identify the selected - or active - map frame? If this is obvious, sorry, but I have not been able to find it. I have a script that creates a polygon from a map frame extent and the user has to enter the map name to make sure I am running on the right map frame (the script picks the map frame based on the map that is selected. Kind of awkward, but may be necessary).&lt;/P&gt;&lt;P&gt;Thank you,&lt;/P&gt;&lt;P&gt;Randy&lt;/P&gt;</description>
      <pubDate>Fri, 08 Dec 2023 14:43:55 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-do-i-set-the-map-in-a-layout-mapframe-with/m-p/1358556#M69364</guid>
      <dc:creator>RandyMcGregor_BMcD</dc:creator>
      <dc:date>2023-12-08T14:43:55Z</dc:date>
    </item>
  </channel>
</rss>

