<?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: Zoom Out Slightly When Using getLayerExtent() To Set Extent of Map Frame in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/zoom-out-slightly-when-using-getlayerextent-to-set/m-p/1381090#M69851</link>
    <description>&lt;P&gt;This worked so well, thanks for the tip!&lt;/P&gt;</description>
    <pubDate>Mon, 12 Feb 2024 15:54:44 GMT</pubDate>
    <dc:creator>edward33</dc:creator>
    <dc:date>2024-02-12T15:54:44Z</dc:date>
    <item>
      <title>Zoom Out Slightly When Using getLayerExtent() To Set Extent of Map Frame</title>
      <link>https://community.esri.com/t5/python-questions/zoom-out-slightly-when-using-getlayerextent-to-set/m-p/1321848#M68472</link>
      <description>&lt;P&gt;I have a set of layouts where their extents change based on the county being published. Basically, the script&amp;nbsp; sets the definition query of the County layer and then uses&lt;/P&gt;&lt;P&gt;mf.camera.setExtent(mf.getLayerExtent(lyr, False, True))&lt;/P&gt;&lt;P&gt;to move the layout extent. However, this zooms too far in on the county boundaries. The goal is to zoom to the extent of the county layer - n%.&lt;/P&gt;&lt;P&gt;I've attached current results vs goal&lt;/P&gt;</description>
      <pubDate>Wed, 23 Aug 2023 19:09:08 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/zoom-out-slightly-when-using-getlayerextent-to-set/m-p/1321848#M68472</guid>
      <dc:creator>BrettLessner_Nsight</dc:creator>
      <dc:date>2023-08-23T19:09:08Z</dc:date>
    </item>
    <item>
      <title>Re: Zoom Out Slightly When Using getLayerExtent() To Set Extent of Map Frame</title>
      <link>https://community.esri.com/t5/python-questions/zoom-out-slightly-when-using-getlayerextent-to-set/m-p/1321865#M68473</link>
      <description>&lt;P&gt;I've had the same problem.&amp;nbsp; I am forced to set the map's layout scale after my feature is drawn from the x/y coordinates.&amp;nbsp; Here's a snippet of what I do after running a script that collects data from a "utility marking request" that draws the feature from Lat/Long coordinates.&lt;/P&gt;&lt;LI-CODE lang="python"&gt;lyt = aprx.listLayouts()[0]
mf = lyt.listElements("MAPFRAME_ELEMENT", "MainMapFrame")[0]
mf.camera.setExtent(mf.getLayerExtent(lyr, False, True))
mf.camera.scale = 24000.0&lt;/LI-CODE&gt;&lt;P&gt;After the script runs, I have to zoom to the feature using Pro (version 2.9).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I think Esri needs to make the getLayerExtent() to allow for a percentage, like when you "zoom to selected feature" or for a map book layout where you can set a percentage for the feature extent in Pro.&amp;nbsp; Maybe you could submit it as a Python Idea.&amp;nbsp; Just a thought.&lt;/P&gt;</description>
      <pubDate>Wed, 23 Aug 2023 19:37:09 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/zoom-out-slightly-when-using-getlayerextent-to-set/m-p/1321865#M68473</guid>
      <dc:creator>Shauna-RaeBrown</dc:creator>
      <dc:date>2023-08-23T19:37:09Z</dc:date>
    </item>
    <item>
      <title>Re: Zoom Out Slightly When Using getLayerExtent() To Set Extent of Map Frame</title>
      <link>https://community.esri.com/t5/python-questions/zoom-out-slightly-when-using-getlayerextent-to-set/m-p/1321888#M68474</link>
      <description>&lt;P&gt;Thanks for sharing your experience. I'll wait to see if I'm missing an option or setting somewhere, but I think we'll have to.&lt;/P&gt;&lt;P&gt;One alternative we're looking into is finding the extent of the layer, do math on the x/y max/min, and use the updated values to set our extent.&amp;nbsp;&lt;/P&gt;&lt;P&gt;-Brett&lt;/P&gt;</description>
      <pubDate>Wed, 23 Aug 2023 20:11:47 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/zoom-out-slightly-when-using-getlayerextent-to-set/m-p/1321888#M68474</guid>
      <dc:creator>BrettLessner_Nsight</dc:creator>
      <dc:date>2023-08-23T20:11:47Z</dc:date>
    </item>
    <item>
      <title>Re: Zoom Out Slightly When Using getLayerExtent() To Set Extent of Map Frame</title>
      <link>https://community.esri.com/t5/python-questions/zoom-out-slightly-when-using-getlayerextent-to-set/m-p/1329621#M68666</link>
      <description>&lt;P&gt;I have to perform this operation also.&amp;nbsp; Here's what I do that seems to work fine.&lt;BR /&gt;&lt;BR /&gt;After you camera.setExtent like you did:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="TylerT_0-1695049096331.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/80909iE5357A5D6C1AD93F/image-size/medium?v=v2&amp;amp;px=400" role="button" title="TylerT_0-1695049096331.png" alt="TylerT_0-1695049096331.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Notice you can both get and set the camera scale with mf.camera.scale.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;HTH.&lt;BR /&gt;&lt;BR /&gt;Tyler&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 18 Sep 2023 15:01:43 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/zoom-out-slightly-when-using-getlayerextent-to-set/m-p/1329621#M68666</guid>
      <dc:creator>TylerT</dc:creator>
      <dc:date>2023-09-18T15:01:43Z</dc:date>
    </item>
    <item>
      <title>Re: Zoom Out Slightly When Using getLayerExtent() To Set Extent of Map Frame</title>
      <link>https://community.esri.com/t5/python-questions/zoom-out-slightly-when-using-getlayerextent-to-set/m-p/1381090#M69851</link>
      <description>&lt;P&gt;This worked so well, thanks for the tip!&lt;/P&gt;</description>
      <pubDate>Mon, 12 Feb 2024 15:54:44 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/zoom-out-slightly-when-using-getlayerextent-to-set/m-p/1381090#M69851</guid>
      <dc:creator>edward33</dc:creator>
      <dc:date>2024-02-12T15:54:44Z</dc:date>
    </item>
    <item>
      <title>Re: Zoom Out Slightly When Using getLayerExtent() To Set Extent of Map Frame</title>
      <link>https://community.esri.com/t5/python-questions/zoom-out-slightly-when-using-getlayerextent-to-set/m-p/1640505#M74589</link>
      <description>&lt;P&gt;Hello to All,&lt;/P&gt;&lt;P&gt;I was looking for a solution to the same issue &amp;amp; found this thread.&amp;nbsp; We can do this in an ArcMap project with way different syntax, but I'm in the process of migrating that project to Pro.&amp;nbsp; So, I got a little stuck.&lt;/P&gt;&lt;P&gt;Agreed - Tyler's solution worked for me as well.&amp;nbsp; Interesting that when typing &lt;EM&gt;mf.camera&lt;/EM&gt; into Pro's built-in Python window, &lt;EM&gt;scale&lt;/EM&gt; isn't exposed when typing a period after &lt;EM&gt;camera&lt;/EM&gt;.&amp;nbsp; It would be nice if Esri added that to the menu.&amp;nbsp; At first, I didn't think it would work, but what-the-heck, why not give it a try.&amp;nbsp; &lt;EM&gt;Voila!&lt;/EM&gt;&amp;nbsp; It worked.&lt;/P&gt;&lt;P&gt;Let's take this a little further.&amp;nbsp; I like to round up the layout scale once I've zoomed out using the 1.1 factor.&amp;nbsp; Adapting from my old ArcMap script, try adding this:&lt;/P&gt;&lt;P&gt;mf.camera.scale -= mf.camera.scale % -100.&lt;/P&gt;&lt;P&gt;I'm not much of a Python programmer, so maybe someone who's more knowledgeable can combine that line of code with Tyler's code to make it cleaner &amp;amp; more concise.&lt;/P&gt;&lt;P&gt;-Chris&lt;/P&gt;</description>
      <pubDate>Fri, 08 Aug 2025 19:31:23 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/zoom-out-slightly-when-using-getlayerextent-to-set/m-p/1640505#M74589</guid>
      <dc:creator>CMorneau</dc:creator>
      <dc:date>2025-08-08T19:31:23Z</dc:date>
    </item>
    <item>
      <title>Re: Zoom Out Slightly When Using getLayerExtent() To Set Extent of Map Frame</title>
      <link>https://community.esri.com/t5/python-questions/zoom-out-slightly-when-using-getlayerextent-to-set/m-p/1640923#M74591</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/450062"&gt;@CMorneau&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;You can add this line after factoring to round up to nearest 100.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;mf.camera.scale = math.ceil(mf.camera.scale / 100) * 100&lt;/LI-CODE&gt;&lt;P&gt;Note:&amp;nbsp;Add `import math` to your imports.&lt;BR /&gt;&lt;BR /&gt;HTH,&lt;BR /&gt;&lt;BR /&gt;Tyler&lt;/P&gt;</description>
      <pubDate>Mon, 11 Aug 2025 22:37:38 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/zoom-out-slightly-when-using-getlayerextent-to-set/m-p/1640923#M74591</guid>
      <dc:creator>TylerT</dc:creator>
      <dc:date>2025-08-11T22:37:38Z</dc:date>
    </item>
    <item>
      <title>Re: Zoom Out Slightly When Using getLayerExtent() To Set Extent of Map Frame</title>
      <link>https://community.esri.com/t5/python-questions/zoom-out-slightly-when-using-getlayerextent-to-set/m-p/1664782#M74886</link>
      <description>&lt;P&gt;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/530005"&gt;@TylerT&lt;/a&gt;&amp;nbsp;marking as solution as that is super slick!&amp;nbsp; -1 point for having a screen shot vs text so I can't copy/paste lol&lt;/P&gt;&lt;P&gt;thanks!&lt;/P&gt;</description>
      <pubDate>Mon, 10 Nov 2025 22:53:00 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/zoom-out-slightly-when-using-getlayerextent-to-set/m-p/1664782#M74886</guid>
      <dc:creator>DougBrowning</dc:creator>
      <dc:date>2025-11-10T22:53:00Z</dc:date>
    </item>
  </channel>
</rss>

