<?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: Creating a City Select and Zoom tool using arcpy in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/creating-a-city-select-and-zoom-tool-using-arcpy/m-p/235537#M18308</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Garrett,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If it isn't doing anything, can you tell if the active view got refreshed? After you run the script, are your items being selected (maybe manually refresh your view just to see)?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 02 May 2016 19:27:16 GMT</pubDate>
    <dc:creator>AdrianWelsh</dc:creator>
    <dc:date>2016-05-02T19:27:16Z</dc:date>
    <item>
      <title>Creating a City Select and Zoom tool using arcpy</title>
      <link>https://community.esri.com/t5/python-questions/creating-a-city-select-and-zoom-tool-using-arcpy/m-p/235532#M18303</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Working on creating a lab which will allow me to type in a city name into a parameter and it will select that city, add it to the TOC and zoom into it. I'm having trouble getting around certain errors. Please help! &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;import arcpy&lt;/P&gt;&lt;P&gt;from arcpy import mapping&lt;/P&gt;&lt;P&gt;#set workspace&lt;/P&gt;&lt;P&gt;mxd = arcpy.mapping.MapDocument("CURRENT")&lt;/P&gt;&lt;P&gt;#set the dataframe&lt;/P&gt;&lt;P&gt;df = arcpy.mapping.ListDataFrames(mxd, "Layers")[0]&lt;/P&gt;&lt;P&gt;cities = arcpy.mapping.ListLayers(mxd, "Cities")[0]&lt;/P&gt;&lt;P&gt;#Establish variables&lt;/P&gt;&lt;P&gt;cityName = arcpy.GetParameterAsText(0)&lt;/P&gt;&lt;P&gt;#Set variable as the parameter for the city search&lt;/P&gt;&lt;P&gt;arcpy.SelectLayerByAttribute_management("Cities", "NEW_SELECTION", " CITY_NAME = 'cityName' ")&lt;/P&gt;&lt;P&gt;df.zoomToSelectedFeatures()&lt;/P&gt;&lt;P&gt;arcpy.RefreshActiveView()&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 02 May 2016 17:03:42 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/creating-a-city-select-and-zoom-tool-using-arcpy/m-p/235532#M18303</guid>
      <dc:creator>GarrettPullis</dc:creator>
      <dc:date>2016-05-02T17:03:42Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a City Select and Zoom tool using arcpy</title>
      <link>https://community.esri.com/t5/python-questions/creating-a-city-select-and-zoom-tool-using-arcpy/m-p/235533#M18304</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Garrett&lt;/P&gt;&lt;P&gt;&lt;A href="https://community.esri.com/migration-blogpost/55181"&gt;Code Formatting... the basics++&lt;/A&gt; &lt;/P&gt;&lt;P&gt;And the error messages you are getting would be useful, it could be in a number of those lines.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 02 May 2016 17:24:19 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/creating-a-city-select-and-zoom-tool-using-arcpy/m-p/235533#M18304</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2016-05-02T17:24:19Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a City Select and Zoom tool using arcpy</title>
      <link>https://community.esri.com/t5/python-questions/creating-a-city-select-and-zoom-tool-using-arcpy/m-p/235534#M18305</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;import arcpy
mxd = arcpy.mapping.MapDocument("CURRENT")
#set the dataframe
df = arcpy.mapping.ListDataFrames(mxd, "Layers")[0]
cities = arcpy.mapping.ListLayers(mxd, "Cities")[0]
#Establish variables
cityName = arcpy.GetParameterAsText(0)
#Set variable as the parameter for the city search
arcpy.SelectLayerByAttribute_management(cities, "NEW_SELECTION", "CITY_NAME = '{}' ".format(cityName))
df.zoomToSelectedFeatures()
arcpy.RefreshActiveView()&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 11:52:57 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/creating-a-city-select-and-zoom-tool-using-arcpy/m-p/235534#M18305</guid>
      <dc:creator>WesMiller</dc:creator>
      <dc:date>2021-12-11T11:52:57Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a City Select and Zoom tool using arcpy</title>
      <link>https://community.esri.com/t5/python-questions/creating-a-city-select-and-zoom-tool-using-arcpy/m-p/235535#M18306</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The interesting thing was I wasn't receiving any errors. The script would&lt;/P&gt;&lt;P&gt;run through and complete, but nothing would happen in ArcMap. Prior to that&lt;/P&gt;&lt;P&gt;there was an error saying GetParameter wasn't defined. Besides that it&lt;/P&gt;&lt;P&gt;runs, but nothing happens.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 02 May 2016 19:10:30 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/creating-a-city-select-and-zoom-tool-using-arcpy/m-p/235535#M18306</guid>
      <dc:creator>GarrettPullis</dc:creator>
      <dc:date>2016-05-02T19:10:30Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a City Select and Zoom tool using arcpy</title>
      <link>https://community.esri.com/t5/python-questions/creating-a-city-select-and-zoom-tool-using-arcpy/m-p/235536#M18307</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;In your original script this line&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3d3d3d; font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif;"&gt;arcpy.SelectLayerByAttribute_management("Cities", "NEW_SELECTION", " CITY_NAME = 'cityName' ")&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3d3d3d; font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif;"&gt;would have run successful without selecting anything unless you have a value of &lt;SPAN style="color: #3d3d3d; font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif;"&gt; 'cityName' &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3d3d3d; font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif;"&gt;This line &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3d3d3d; font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif;"&gt;&lt;SPAN style="color: #000000; font-family: Consolas, 'Courier New', Courier, mono, serif; font-size: 12px;"&gt;cityName = arcpy.GetParameterAsText(&lt;/SPAN&gt;&lt;SPAN class="number" style="font-size: 12px; font-family: Consolas, 'Courier New', Courier, mono, serif; color: green;"&gt;0&lt;/SPAN&gt;&lt;SPAN style="font-size: 12px; font-family: Consolas, 'Courier New', Courier, mono, serif; color: #000000;"&gt;)&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000000; font-size: 12px; font-family: Consolas, 'Courier New', Courier, mono, serif;"&gt;is used for an external variable most common would be model builder &lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 02 May 2016 19:16:15 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/creating-a-city-select-and-zoom-tool-using-arcpy/m-p/235536#M18307</guid>
      <dc:creator>WesMiller</dc:creator>
      <dc:date>2016-05-02T19:16:15Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a City Select and Zoom tool using arcpy</title>
      <link>https://community.esri.com/t5/python-questions/creating-a-city-select-and-zoom-tool-using-arcpy/m-p/235537#M18308</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Garrett,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If it isn't doing anything, can you tell if the active view got refreshed? After you run the script, are your items being selected (maybe manually refresh your view just to see)?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 02 May 2016 19:27:16 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/creating-a-city-select-and-zoom-tool-using-arcpy/m-p/235537#M18308</guid>
      <dc:creator>AdrianWelsh</dc:creator>
      <dc:date>2016-05-02T19:27:16Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a City Select and Zoom tool using arcpy</title>
      <link>https://community.esri.com/t5/python-questions/creating-a-city-select-and-zoom-tool-using-arcpy/m-p/235538#M18309</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The only thing that we were able to make it do was select all the cities&lt;/P&gt;&lt;P&gt;rather than the one particular city that we input&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 03 May 2016 15:07:33 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/creating-a-city-select-and-zoom-tool-using-arcpy/m-p/235538#M18309</guid>
      <dc:creator>GarrettPullis</dc:creator>
      <dc:date>2016-05-03T15:07:33Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a City Select and Zoom tool using arcpy</title>
      <link>https://community.esri.com/t5/python-questions/creating-a-city-select-and-zoom-tool-using-arcpy/m-p/235539#M18310</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Change this line &lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 12px; font-family: Consolas, 'Courier New', Courier, mono, serif; color: #000000;"&gt;cityName = arcpy.GetParameterAsText(&lt;/SPAN&gt;&lt;SPAN class="number" style="font-size: 12px; font-family: Consolas, 'Courier New', Courier, mono, serif; color: green;"&gt;0&lt;/SPAN&gt;&lt;SPAN style="font-size: 12px; font-family: Consolas, 'Courier New', Courier, mono, serif; color: #000000;"&gt;)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 12px; font-family: Consolas, 'Courier New', Courier, mono, serif; color: #000000;"&gt;to &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 12px; font-family: Consolas, 'Courier New', Courier, mono, serif; color: #000000;"&gt;&lt;SPAN style="font-size: 12px; font-family: Consolas, 'Courier New', Courier, mono, serif; color: #000000;"&gt;cityName = 'A Known City Name'&lt;/SPAN&gt;&lt;SPAN style="font-size: 12px; font-family: Consolas, 'Courier New', Courier, mono, serif; color: #000000;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 03 May 2016 15:09:05 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/creating-a-city-select-and-zoom-tool-using-arcpy/m-p/235539#M18310</guid>
      <dc:creator>WesMiller</dc:creator>
      <dc:date>2016-05-03T15:09:05Z</dc:date>
    </item>
  </channel>
</rss>

