<?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 Set extent to aprx with Python in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/set-extent-to-aprx-with-python/m-p/435947#M34257</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi all&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have an aprx with one map and one layer.&lt;/P&gt;&lt;P&gt;I want to change the extent of the aprx with Python so when the user open the aprx the extent will be full extent (it was save with wrong extent.&lt;/P&gt;&lt;P&gt;I tried the very simple code below, it does not gives an error and the aprx is saved but the extent is unchanged.&lt;/P&gt;&lt;P&gt;When I uncomment the zoomToAllLayers I get an error.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;There is some solutions with layout (I do not have it in this aprx).&lt;/P&gt;&lt;P&gt;If I work with the CURRENT aprx then the activeView give me mapView that is working but I do want it to run without open the aprx.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Any ideas?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;&lt;SPAN class="keyword token"&gt;import&lt;/SPAN&gt; arcpy
aprx &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;mp&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;ArcGISProject&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;r&lt;SPAN class="string token"&gt;"xx.aprx"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
map1 &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; aprx&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;listMaps&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;0&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;
mapView &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; map1&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;defaultView
lyr &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; map1&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;listLayers&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;0&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;
desc &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;Describe&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;lyr&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
&lt;SPAN class="keyword token"&gt;print&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt; str&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;desc&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;extent&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
mapView&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;camera&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;setExtent&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;desc&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;extent&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
&lt;SPAN class="comment token"&gt;#mapView.zoomToAllLayers()&lt;/SPAN&gt;
aprx&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;save&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sat, 11 Dec 2021 19:32:04 GMT</pubDate>
    <dc:creator>ModyBuchbinder</dc:creator>
    <dc:date>2021-12-11T19:32:04Z</dc:date>
    <item>
      <title>Set extent to aprx with Python</title>
      <link>https://community.esri.com/t5/python-questions/set-extent-to-aprx-with-python/m-p/435947#M34257</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi all&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have an aprx with one map and one layer.&lt;/P&gt;&lt;P&gt;I want to change the extent of the aprx with Python so when the user open the aprx the extent will be full extent (it was save with wrong extent.&lt;/P&gt;&lt;P&gt;I tried the very simple code below, it does not gives an error and the aprx is saved but the extent is unchanged.&lt;/P&gt;&lt;P&gt;When I uncomment the zoomToAllLayers I get an error.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;There is some solutions with layout (I do not have it in this aprx).&lt;/P&gt;&lt;P&gt;If I work with the CURRENT aprx then the activeView give me mapView that is working but I do want it to run without open the aprx.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Any ideas?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;&lt;SPAN class="keyword token"&gt;import&lt;/SPAN&gt; arcpy
aprx &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;mp&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;ArcGISProject&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;r&lt;SPAN class="string token"&gt;"xx.aprx"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
map1 &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; aprx&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;listMaps&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;0&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;
mapView &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; map1&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;defaultView
lyr &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; map1&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;listLayers&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;0&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;
desc &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;Describe&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;lyr&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
&lt;SPAN class="keyword token"&gt;print&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt; str&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;desc&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;extent&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
mapView&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;camera&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;setExtent&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;desc&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;extent&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
&lt;SPAN class="comment token"&gt;#mapView.zoomToAllLayers()&lt;/SPAN&gt;
aprx&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;save&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 19:32:04 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/set-extent-to-aprx-with-python/m-p/435947#M34257</guid>
      <dc:creator>ModyBuchbinder</dc:creator>
      <dc:date>2021-12-11T19:32:04Z</dc:date>
    </item>
    <item>
      <title>Re: Set extent to aprx with Python</title>
      <link>https://community.esri.com/t5/python-questions/set-extent-to-aprx-with-python/m-p/1043945#M60672</link>
      <description>&lt;P&gt;ever figure this out?&lt;/P&gt;</description>
      <pubDate>Mon, 05 Apr 2021 19:53:32 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/set-extent-to-aprx-with-python/m-p/1043945#M60672</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2021-04-05T19:53:32Z</dc:date>
    </item>
    <item>
      <title>Re: Set extent to aprx with Python</title>
      <link>https://community.esri.com/t5/python-questions/set-extent-to-aprx-with-python/m-p/1044083#M60688</link>
      <description>&lt;P&gt;No. I could not find any way to change any other aprx but the CURRENT one.&lt;/P&gt;&lt;P&gt;I found a few other methods in arcpy.mp that works only on the current aprx so I think it is a limitation.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 06 Apr 2021 05:34:35 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/set-extent-to-aprx-with-python/m-p/1044083#M60688</guid>
      <dc:creator>mody_buchbinder</dc:creator>
      <dc:date>2021-04-06T05:34:35Z</dc:date>
    </item>
  </channel>
</rss>

