<?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 the extent of a dataframe in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/set-the-extent-of-a-dataframe/m-p/124883#M9714</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;In my script I select a feature (layer with definition query) and set the extent of the dataframe to the extent of this feature. This works fine, as long as just one feature is selected.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Sometimes though, two features need to be selected. In this case, I do get the extent of the features and I can set the extent of the dataframe, but nothing gets drawn.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Here's my code:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; Layer_xy.definitionQuery = DefinitionQuery

&amp;nbsp;&amp;nbsp;&amp;nbsp; newExtent = Layer_xy.getExtent(True)
#&amp;nbsp; newExtent = Layer_xy.getSelectedExtent(True)
&amp;nbsp;&amp;nbsp;&amp;nbsp; df.extent = newExtent
&amp;nbsp;&amp;nbsp;&amp;nbsp; df.panToExtent(df.extent)
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; print "Extent of feature:\nXMin: %f, YMin: %f, \nXMax: %f, YMax: %f" % \
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; (df.extent.XMin,df.extent.YMin,df.extent.XMax,df.extent.YMax)
&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I tried it both with Layer_xy.getExtent and Layer_xy.getSelectedExtent and with or without panToExtent, with Layer_xy.getSelectedExtent(True) or (False), but nothing was ever drawn...&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Any suggestions? Thanks for your help.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Vera&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 07 Dec 2011 14:44:19 GMT</pubDate>
    <dc:creator>VeraDiaz-Köhli</dc:creator>
    <dc:date>2011-12-07T14:44:19Z</dc:date>
    <item>
      <title>set the extent of a dataframe</title>
      <link>https://community.esri.com/t5/python-questions/set-the-extent-of-a-dataframe/m-p/124883#M9714</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;In my script I select a feature (layer with definition query) and set the extent of the dataframe to the extent of this feature. This works fine, as long as just one feature is selected.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Sometimes though, two features need to be selected. In this case, I do get the extent of the features and I can set the extent of the dataframe, but nothing gets drawn.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Here's my code:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; Layer_xy.definitionQuery = DefinitionQuery

&amp;nbsp;&amp;nbsp;&amp;nbsp; newExtent = Layer_xy.getExtent(True)
#&amp;nbsp; newExtent = Layer_xy.getSelectedExtent(True)
&amp;nbsp;&amp;nbsp;&amp;nbsp; df.extent = newExtent
&amp;nbsp;&amp;nbsp;&amp;nbsp; df.panToExtent(df.extent)
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; print "Extent of feature:\nXMin: %f, YMin: %f, \nXMax: %f, YMax: %f" % \
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; (df.extent.XMin,df.extent.YMin,df.extent.XMax,df.extent.YMax)
&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I tried it both with Layer_xy.getExtent and Layer_xy.getSelectedExtent and with or without panToExtent, with Layer_xy.getSelectedExtent(True) or (False), but nothing was ever drawn...&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Any suggestions? Thanks for your help.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Vera&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 07 Dec 2011 14:44:19 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/set-the-extent-of-a-dataframe/m-p/124883#M9714</guid>
      <dc:creator>VeraDiaz-Köhli</dc:creator>
      <dc:date>2011-12-07T14:44:19Z</dc:date>
    </item>
    <item>
      <title>Re: set the extent of a dataframe</title>
      <link>https://community.esri.com/t5/python-questions/set-the-extent-of-a-dataframe/m-p/124884#M9715</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Have you tried RefreshActiveView?&amp;nbsp; Here is a sample of I use of something similar to what you are trying to do:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&amp;nbsp; df.extent = ParcelLayer.getSelectedExtent()
&amp;nbsp; df.scale = df.scale * 1.1&amp;nbsp; #&amp;nbsp; Add 10 percent to the extent
&amp;nbsp; arcpy.RefreshActiveView()&amp;nbsp; #&amp;nbsp; Force a redraw&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 07:08:04 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/set-the-extent-of-a-dataframe/m-p/124884#M9715</guid>
      <dc:creator>DaveJordan1</dc:creator>
      <dc:date>2021-12-11T07:08:04Z</dc:date>
    </item>
    <item>
      <title>Re: set the extent of a dataframe</title>
      <link>https://community.esri.com/t5/python-questions/set-the-extent-of-a-dataframe/m-p/124885#M9716</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;It's working! My script is quite long by now and setting the extent of this dataframe on my layout is just one small part. &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I tried exporting the map to a pdf right after I set the extent and it was drawn correctly. My problem was, that later in the script I set the size of the dataframe explicitly in a loop through all my layout-elements.&amp;nbsp; For some reason, whenever two features are selected the size of the dataframe is set to a size that doesn't fit on the layout anymore and consequently nothing is drawn. &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Now I don't set the size anymore, and it works ok.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Vera&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 08 Dec 2011 07:11:27 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/set-the-extent-of-a-dataframe/m-p/124885#M9716</guid>
      <dc:creator>VeraDiaz-Köhli</dc:creator>
      <dc:date>2011-12-08T07:11:27Z</dc:date>
    </item>
  </channel>
</rss>

