<?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 If i have the extents for a layer how do i get ArcGIS to center the drawing in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/if-i-have-the-extents-for-a-layer-how-do-i-get/m-p/392633#M31056</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have the following code:&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;import arcpy

#mxd = arcpy.mapping.MapDocument("CURRENT")
mxd = arcpy.mapping.MapDocument(r"C:/GISMAPS/LUS Map.mxd")
df = arcpy.mapping.ListDataFrames(mxd)[0]
OHLayer = arcpy.mapping.ListLayers(mxd, "Primary OH", df)[0]

df.extent = OHLayer.getSelectedExtent(False)
#df.scale = df.scale * 1.1
extent = ({df.extent.XMin}, {df.extent.YMin}, {df.extent.XMax}, {df.extent.YMax})

print('XMin: {}, YMin: {}'.format(df.extent.XMin, df.extent.YMin))
print('XMax: {}, YMax: {}'.format(df.extent.XMax, df.extent.YMax))

arcpy.RefreshActiveView()
del mxd&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;/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;P&gt;This is the output for lines 12 and 13&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG class="image-1 jive-image" src="https://community.esri.com/legacyfs/online/477643_pastedImage_1.png" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;How do i center this drawing so that section of map is displayed on the screen? I have the extents but do not know how to use them to do this.&lt;/P&gt;&lt;P&gt;Thanks for any help.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sat, 11 Dec 2021 17:59:41 GMT</pubDate>
    <dc:creator>RickHawkins</dc:creator>
    <dc:date>2021-12-11T17:59:41Z</dc:date>
    <item>
      <title>If i have the extents for a layer how do i get ArcGIS to center the drawing</title>
      <link>https://community.esri.com/t5/python-questions/if-i-have-the-extents-for-a-layer-how-do-i-get/m-p/392633#M31056</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have the following code:&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;import arcpy

#mxd = arcpy.mapping.MapDocument("CURRENT")
mxd = arcpy.mapping.MapDocument(r"C:/GISMAPS/LUS Map.mxd")
df = arcpy.mapping.ListDataFrames(mxd)[0]
OHLayer = arcpy.mapping.ListLayers(mxd, "Primary OH", df)[0]

df.extent = OHLayer.getSelectedExtent(False)
#df.scale = df.scale * 1.1
extent = ({df.extent.XMin}, {df.extent.YMin}, {df.extent.XMax}, {df.extent.YMax})

print('XMin: {}, YMin: {}'.format(df.extent.XMin, df.extent.YMin))
print('XMax: {}, YMax: {}'.format(df.extent.XMax, df.extent.YMax))

arcpy.RefreshActiveView()
del mxd&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;/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;P&gt;This is the output for lines 12 and 13&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG class="image-1 jive-image" src="https://community.esri.com/legacyfs/online/477643_pastedImage_1.png" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;How do i center this drawing so that section of map is displayed on the screen? I have the extents but do not know how to use them to do this.&lt;/P&gt;&lt;P&gt;Thanks for any help.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 17:59:41 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/if-i-have-the-extents-for-a-layer-how-do-i-get/m-p/392633#M31056</guid>
      <dc:creator>RickHawkins</dc:creator>
      <dc:date>2021-12-11T17:59:41Z</dc:date>
    </item>
    <item>
      <title>Re: If i have the extents for a layer how do i get ArcGIS to center the drawing</title>
      <link>https://community.esri.com/t5/python-questions/if-i-have-the-extents-for-a-layer-how-do-i-get/m-p/392634#M31057</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Rick,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This may work for you:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;df&lt;SPAN style="color: #333333;"&gt;.&lt;/SPAN&gt;panToExtent(df&lt;SPAN style="color: #333333;"&gt;.&lt;/SPAN&gt;getSelectedExtent())&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="" style="color: #4d4d4d;"&gt;You can read more here:&amp;nbsp;&lt;A class="link-titled" href="https://desktop.arcgis.com/en/arcmap/10.3/analyze/arcpy-mapping/dataframe-class.htm" title="https://desktop.arcgis.com/en/arcmap/10.3/analyze/arcpy-mapping/dataframe-class.htm"&gt;DataFrame—Help | ArcGIS for Desktop&lt;/A&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="" style="color: #4d4d4d;"&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="" style="color: #4d4d4d;"&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 08 Jan 2020 16:15:27 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/if-i-have-the-extents-for-a-layer-how-do-i-get/m-p/392634#M31057</guid>
      <dc:creator>HannesZiegler</dc:creator>
      <dc:date>2020-01-08T16:15:27Z</dc:date>
    </item>
    <item>
      <title>Re: If i have the extents for a layer how do i get ArcGIS to center the drawing</title>
      <link>https://community.esri.com/t5/python-questions/if-i-have-the-extents-for-a-layer-how-do-i-get/m-p/392635#M31058</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Line 08 of your code&lt;/P&gt;&lt;PRE class=""&gt;&lt;BLOCKQUOTE class="jive_macro_quote jive-quote jive_text_macro"&gt;&lt;CODE&gt;df.extent = OHLayer.getSelectedExtent(False)&lt;/CODE&gt;&lt;/BLOCKQUOTE&gt;&lt;/PRE&gt;&lt;P&gt;should both center and zoom the dataframe to the extent of the selected object.&amp;nbsp; I just tested it again, and it works.&amp;nbsp; Do you only want to center and not zoom?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 08 Jan 2020 16:21:56 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/if-i-have-the-extents-for-a-layer-how-do-i-get/m-p/392635#M31058</guid>
      <dc:creator>JoshuaBixby</dc:creator>
      <dc:date>2020-01-08T16:21:56Z</dc:date>
    </item>
    <item>
      <title>Re: If i have the extents for a layer how do i get ArcGIS to center the drawing</title>
      <link>https://community.esri.com/t5/python-questions/if-i-have-the-extents-for-a-layer-how-do-i-get/m-p/392636#M31059</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;yes i would like to zoom also. Another question that i had is what does the df.extent show. For example in the table of contents it shows the layer Primary OH with individual feeders shown below. The user will select 1 feeder to show on the display and i would want to use the extents for the feeder. So does df.extent show for the layer or can it show just the extents for the feeder selected?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG class="image-1 jive-image" src="https://community.esri.com/legacyfs/online/477729_pastedImage_3.png" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks for the help&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 08 Jan 2020 18:11:56 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/if-i-have-the-extents-for-a-layer-how-do-i-get/m-p/392636#M31059</guid>
      <dc:creator>RickHawkins</dc:creator>
      <dc:date>2020-01-08T18:11:56Z</dc:date>
    </item>
    <item>
      <title>Re: If i have the extents for a layer how do i get ArcGIS to center the drawing</title>
      <link>https://community.esri.com/t5/python-questions/if-i-have-the-extents-for-a-layer-how-do-i-get/m-p/392637#M31060</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The &lt;SPAN style="font-family: courier new, courier, monospace;"&gt;df.extent&lt;/SPAN&gt; shows just that, the extent of the data frame itself regardless of what data layers are loaded and what data is selected.&amp;nbsp; That said, &lt;SPAN style="font-family: courier new, courier, monospace;"&gt;df.extent&lt;/SPAN&gt; is also writable, so you can set the property to change the extent of the dataframe.&amp;nbsp; This is why I said Line 08 of your earlier code should both center and zoom the dataframe to the selected feature in the layer.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 08 Jan 2020 19:07:22 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/if-i-have-the-extents-for-a-layer-how-do-i-get/m-p/392637#M31060</guid>
      <dc:creator>JoshuaBixby</dc:creator>
      <dc:date>2020-01-08T19:07:22Z</dc:date>
    </item>
    <item>
      <title>Re: If i have the extents for a layer how do i get ArcGIS to center the drawing</title>
      <link>https://community.esri.com/t5/python-questions/if-i-have-the-extents-for-a-layer-how-do-i-get/m-p/392638#M31061</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks for the help. Appreciate it.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 08 Jan 2020 19:28:27 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/if-i-have-the-extents-for-a-layer-how-do-i-get/m-p/392638#M31061</guid>
      <dc:creator>RickHawkins</dc:creator>
      <dc:date>2020-01-08T19:28:27Z</dc:date>
    </item>
  </channel>
</rss>

