<?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 Custom Toolbar Button in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/creating-a-custom-toolbar-button/m-p/707279#M54804</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;If you just need to enter a value and zoom to that feature you can make a simple script tool, something along these lines. Add it to a toolbox and then make it a button.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;import arcpy
arcpy.AddMessage("Starting")
city = arcpy.GetParameterAsText(0)
arcpy.AddMessage(city)
mxd = arcpy.mapping.MapDocument("CURRENT")
df = arcpy.mapping.ListDataFrames(mxd, "Main Map")[0]
lyr = arcpy.mapping.ListLayers(mxd, "Cities, Towns and Urban Service Areas", df)[0]
arcpy.AddMessage(lyr.name)
expression = "NAME = '"+city+"'"
arcpy.AddMessage(expression)
arcpy.SelectLayerByAttribute_management(lyr,"NEW_SELECTION",expression)
df.extent = lyr.getSelectedExtent()
df.scale = df.scale*1.2
arcpy.RefreshActiveView()
&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sun, 12 Dec 2021 05:43:05 GMT</pubDate>
    <dc:creator>MathewCoyle</dc:creator>
    <dc:date>2021-12-12T05:43:05Z</dc:date>
    <item>
      <title>Creating a Custom Toolbar Button</title>
      <link>https://community.esri.com/t5/python-questions/creating-a-custom-toolbar-button/m-p/707277#M54802</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;SPAN&gt;I'm not sure if this is where I should post this but if someone could point me in the right direction of learning how to do this, I'd be forever grateful.....I would like to create a custom toolbar button that I can add to my ArcMap.mxd that will run a select and prompt me for a parcel number, and after keying the number in it will zoom to the selected parcel.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I would appreciate any help! Thanks!&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Kim&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 07 Sep 2011 16:14:44 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/creating-a-custom-toolbar-button/m-p/707277#M54802</guid>
      <dc:creator>KimBeckwell</dc:creator>
      <dc:date>2011-09-07T16:14:44Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a Custom Toolbar Button</title>
      <link>https://community.esri.com/t5/python-questions/creating-a-custom-toolbar-button/m-p/707278#M54803</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Should I use a VBA macro?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 07 Sep 2011 18:54:27 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/creating-a-custom-toolbar-button/m-p/707278#M54803</guid>
      <dc:creator>KimBeckwell</dc:creator>
      <dc:date>2011-09-07T18:54:27Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a Custom Toolbar Button</title>
      <link>https://community.esri.com/t5/python-questions/creating-a-custom-toolbar-button/m-p/707279#M54804</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;If you just need to enter a value and zoom to that feature you can make a simple script tool, something along these lines. Add it to a toolbox and then make it a button.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;import arcpy
arcpy.AddMessage("Starting")
city = arcpy.GetParameterAsText(0)
arcpy.AddMessage(city)
mxd = arcpy.mapping.MapDocument("CURRENT")
df = arcpy.mapping.ListDataFrames(mxd, "Main Map")[0]
lyr = arcpy.mapping.ListLayers(mxd, "Cities, Towns and Urban Service Areas", df)[0]
arcpy.AddMessage(lyr.name)
expression = "NAME = '"+city+"'"
arcpy.AddMessage(expression)
arcpy.SelectLayerByAttribute_management(lyr,"NEW_SELECTION",expression)
df.extent = lyr.getSelectedExtent()
df.scale = df.scale*1.2
arcpy.RefreshActiveView()
&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 05:43:05 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/creating-a-custom-toolbar-button/m-p/707279#M54804</guid>
      <dc:creator>MathewCoyle</dc:creator>
      <dc:date>2021-12-12T05:43:05Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a Custom Toolbar Button</title>
      <link>https://community.esri.com/t5/python-questions/creating-a-custom-toolbar-button/m-p/707280#M54805</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Matthew, You are awesome! Thank You!&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 08 Sep 2011 15:46:07 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/creating-a-custom-toolbar-button/m-p/707280#M54805</guid>
      <dc:creator>KimBeckwell</dc:creator>
      <dc:date>2011-09-08T15:46:07Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a Custom Toolbar Button</title>
      <link>https://community.esri.com/t5/python-questions/creating-a-custom-toolbar-button/m-p/707281#M54806</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;All,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I am new to Python scripting.&amp;nbsp; I am attempting to modify the code provided.&amp;nbsp; I have a Parcels Feature Class and want to search based on a RENUM attribute field.&amp;nbsp; I am running into a SyntaxError on line 5 .&amp;nbsp; Any ideas why?&amp;nbsp; Thanks. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;&lt;BLOCKQUOTE&gt;&lt;/BLOCKQUOTE&gt;&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 17 Jul 2013 13:24:10 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/creating-a-custom-toolbar-button/m-p/707281#M54806</guid>
      <dc:creator>JacobDrvar</dc:creator>
      <dc:date>2013-07-17T13:24:10Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a Custom Toolbar Button</title>
      <link>https://community.esri.com/t5/python-questions/creating-a-custom-toolbar-button/m-p/707282#M54807</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I am modifying the script to Search the field RENUM from a Parcels Feature Class.&amp;nbsp; When, I run the script I receive the following error:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Executing: SelectLayerByAttribute GPL0 NEW_SELECTION 2205529&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Start Time: Thu Jul 18 07:56:47 2013&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;ERROR 000358: Invalid expression&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;An invalid SQL statement was used.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;An invalid SQL statement was used. [Parcels]&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;An invalid SQL statement was used. [SELECT OBJECTID FROM Parcels WHERE 2205529]&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Failed to execute (SelectLayerByAttribute).&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;2205529 is a valid record within the RENUM field that I enter into the Script.&amp;nbsp; The tool runs, but the record is not selected.&amp;nbsp; What am I overlooking?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;My script is shown below:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;#Import modules
import arcpy
arcpy.AddMessage("Start")

#Variables
Parcels = arcpy.GetParameterAsText(0)
arcpy.AddMessage(Parcels)

mxd = arcpy.mapping.MapDocument("CURRENT")
df = arcpy.mapping.ListDataFrames(mxd, "Layers")[0]
lyr = arcpy.mapping.ListLayers(mxd, "Parcels", df)[0]
arcpy.AddMessage(lyr.name)

#Logic
try:
 whereClause = "RENUM = '"+Parcels+"'"
 arcpy.AddMessage("whereClause")

 arcpy.SelectLayerByAttribute_management(lyr, "NEW_SELECTION", whereClause)
 arcpy.AddMessage("Selection")

except:
 exit()&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 05:43:08 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/creating-a-custom-toolbar-button/m-p/707282#M54807</guid>
      <dc:creator>JacobDrvar</dc:creator>
      <dc:date>2021-12-12T05:43:08Z</dc:date>
    </item>
  </channel>
</rss>

