<?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 get extent of selected features in layer - zoom to/locate script in mxd in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/get-extent-of-selected-features-in-layer-zoom-to/m-p/76539#M6213</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi!&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I need to make a script that does something like "zoom to/locate" = in ArcMap, user types a ID of an feature and map zooms to the feature... It needs to be independent on data in current mxd.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;My idea is to do it like this:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;import arcpy
dtb="Database Connections\mygdtb.sde"
arcpy.env.workspace=dtb
searchedLayer="MYGDTB.DATAOWNER.searchedLayer"
searchedValue=arcpy.GetParameterAsText(0)
sql="[searchedField]='"+searchedValue+"'"
lyr=arcpy.MakeFeatureLayer_management(searchedLayer, "lyr")
selectedItem=arcpy.SelectLayerByAttribute_management(lyr,"NEW_SELECTION",sql)&lt;/PRE&gt;&lt;BR /&gt;&lt;SPAN&gt;and than use &lt;/SPAN&gt;&lt;A href="http://resources.arcgis.com/en/help/main/10.2/index.html#//00s300000008000000" rel="nofollow noopener noreferrer" target="_blank"&gt;layer´s method getSelectedExtent&lt;/A&gt;&lt;SPAN&gt;, than pass that extent to current mxd and zoom it to that extent... &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;But it doesn´t work that way - I´m not able to get extent of selected features.... How to do it? Any ideas?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I would appreciate any help... Thank you!&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 10 Dec 2021 22:57:41 GMT</pubDate>
    <dc:creator>J_B__K_</dc:creator>
    <dc:date>2021-12-10T22:57:41Z</dc:date>
    <item>
      <title>get extent of selected features in layer - zoom to/locate script in mxd</title>
      <link>https://community.esri.com/t5/python-questions/get-extent-of-selected-features-in-layer-zoom-to/m-p/76539#M6213</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi!&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I need to make a script that does something like "zoom to/locate" = in ArcMap, user types a ID of an feature and map zooms to the feature... It needs to be independent on data in current mxd.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;My idea is to do it like this:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;import arcpy
dtb="Database Connections\mygdtb.sde"
arcpy.env.workspace=dtb
searchedLayer="MYGDTB.DATAOWNER.searchedLayer"
searchedValue=arcpy.GetParameterAsText(0)
sql="[searchedField]='"+searchedValue+"'"
lyr=arcpy.MakeFeatureLayer_management(searchedLayer, "lyr")
selectedItem=arcpy.SelectLayerByAttribute_management(lyr,"NEW_SELECTION",sql)&lt;/PRE&gt;&lt;BR /&gt;&lt;SPAN&gt;and than use &lt;/SPAN&gt;&lt;A href="http://resources.arcgis.com/en/help/main/10.2/index.html#//00s300000008000000" rel="nofollow noopener noreferrer" target="_blank"&gt;layer´s method getSelectedExtent&lt;/A&gt;&lt;SPAN&gt;, than pass that extent to current mxd and zoom it to that extent... &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;But it doesn´t work that way - I´m not able to get extent of selected features.... How to do it? Any ideas?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I would appreciate any help... Thank you!&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 Dec 2021 22:57:41 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/get-extent-of-selected-features-in-layer-zoom-to/m-p/76539#M6213</guid>
      <dc:creator>J_B__K_</dc:creator>
      <dc:date>2021-12-10T22:57:41Z</dc:date>
    </item>
  </channel>
</rss>

