Hi all
I have an aprx with one map and one layer.
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.
I tried the very simple code below, it does not gives an error and the aprx is saved but the extent is unchanged.
When I uncomment the zoomToAllLayers I get an error.
There is some solutions with layout (I do not have it in this aprx).
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.
Any ideas?
<SPAN class="keyword token">import</SPAN> arcpy
aprx <SPAN class="operator token">=</SPAN> arcpy<SPAN class="punctuation token">.</SPAN>mp<SPAN class="punctuation token">.</SPAN>ArcGISProject<SPAN class="punctuation token">(</SPAN>r<SPAN class="string token">"xyz.aprx"</SPAN><SPAN class="punctuation token">)</SPAN>
map1 <SPAN class="operator token">=</SPAN> aprx<SPAN class="punctuation token">.</SPAN>listMaps<SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">[</SPAN><SPAN class="number token">0</SPAN><SPAN class="punctuation token">]</SPAN>
mapView <SPAN class="operator token">=</SPAN> map1<SPAN class="punctuation token">.</SPAN>defaultView
lyr <SPAN class="operator token">=</SPAN> map1<SPAN class="punctuation token">.</SPAN>listLayers<SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">[</SPAN><SPAN class="number token">0</SPAN><SPAN class="punctuation token">]</SPAN>
desc <SPAN class="operator token">=</SPAN> arcpy<SPAN class="punctuation token">.</SPAN>Describe<SPAN class="punctuation token">(</SPAN>lyr<SPAN class="punctuation token">)</SPAN>
<SPAN class="keyword token">print</SPAN> <SPAN class="punctuation token">(</SPAN> str<SPAN class="punctuation token">(</SPAN>desc<SPAN class="punctuation token">.</SPAN>extent<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">)</SPAN>
mapView<SPAN class="punctuation token">.</SPAN>camera<SPAN class="punctuation token">.</SPAN>setExtent<SPAN class="punctuation token">(</SPAN>desc<SPAN class="punctuation token">.</SPAN>extent<SPAN class="punctuation token">)</SPAN>
<SPAN class="comment token">#mapView.zoomToAllLayers()</SPAN>
aprx<SPAN class="punctuation token">.</SPAN>save<SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="line-numbers-rows"><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN></SPAN>