<?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: What is Parameter.name used for in python toolbox in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/what-is-parameter-name-used-for-in-python-toolbox/m-p/591666#M46383</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;most likely, but in some pure python code I've seen code similar to&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;getParameter(param0.Name&lt;CODE&gt;&lt;SPAN&gt;)&amp;nbsp;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/P&gt;&lt;P&gt;&lt;CODE&gt;&lt;/CODE&gt;&lt;/P&gt;&lt;P&gt;&lt;CODE&gt;&lt;SPAN&gt; you might try arcpy.getParameter("in_features"), were in_feature is a name of a parameter, and see if it works. &lt;/SPAN&gt;&lt;/CODE&gt;&lt;/P&gt;&lt;P&gt;&lt;CODE&gt;&lt;/CODE&gt;&lt;/P&gt;&lt;P&gt;&lt;CODE&gt;&lt;SPAN&gt;If it does let us know :-)&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 12 Dec 2017 17:03:38 GMT</pubDate>
    <dc:creator>RichardDaniels</dc:creator>
    <dc:date>2017-12-12T17:03:38Z</dc:date>
    <item>
      <title>What is Parameter.name used for in python toolbox</title>
      <link>https://community.esri.com/t5/python-questions/what-is-parameter-name-used-for-in-python-toolbox/m-p/591661#M46378</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;According to the python toolbox documentation, a Parameter's name attribute is:&amp;nbsp;&lt;/P&gt;&lt;BLOCKQUOTE class="jive_macro_quote jive-quote jive_text_macro"&gt;&lt;P&gt;&lt;SPAN style="color: #4d4d4d; background-color: #ffffff;"&gt;The parameter name as shown in the tool's syntax in Python.&lt;/SPAN&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;Right.&amp;nbsp; That doesn't mean much.&amp;nbsp; What is it used for?&amp;nbsp; Can I reference a parameter with it in code?&lt;/P&gt;&lt;P&gt;So some tool dialog's get burdened with parameters.&amp;nbsp; Are we really supposed to refer to all by index and remember the order?&amp;nbsp; When we move things around, renumber our code?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;There's got to be a better way, but I'm still looking.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 06 Dec 2017 19:42:14 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/what-is-parameter-name-used-for-in-python-toolbox/m-p/591661#M46378</guid>
      <dc:creator>LizEidsness</dc:creator>
      <dc:date>2017-12-06T19:42:14Z</dc:date>
    </item>
    <item>
      <title>Re: What is Parameter.name used for in python toolbox</title>
      <link>https://community.esri.com/t5/python-questions/what-is-parameter-name-used-for-in-python-toolbox/m-p/591662#M46379</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Within a python program you can do this to get the values from the Model Process that called it.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;#Check to see if we have the expected number of parameters, in this case 2&lt;/P&gt;&lt;P&gt;if arcpy.GetParameterCount !=2:&lt;BR /&gt;&amp;nbsp;&amp;nbsp;print "Script requires two arguments (table file name and a field name)."&lt;BR /&gt;&amp;nbsp;&amp;nbsp;raise Exception&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;# Gets the value from the Model Process&lt;BR /&gt;theFileName= arcpy.getparameterastext(0)&lt;/P&gt;&lt;P&gt;theFieldName= arcpy.getparameterastext(1)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Some coders also use&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;theFileName= sys.argv[1].lower()&lt;/P&gt;&lt;P&gt;theFieldName=sys.argv[2].lower()&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In this case sys.argv[0] would be the name of the 'program' itself.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Rich&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 06 Dec 2017 19:58:45 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/what-is-parameter-name-used-for-in-python-toolbox/m-p/591662#M46379</guid>
      <dc:creator>RichardDaniels</dc:creator>
      <dc:date>2017-12-06T19:58:45Z</dc:date>
    </item>
    <item>
      <title>Re: What is Parameter.name used for in python toolbox</title>
      <link>https://community.esri.com/t5/python-questions/what-is-parameter-name-used-for-in-python-toolbox/m-p/591663#M46380</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Right, but that's not what I mean.&amp;nbsp; In a Python Toolbox specifically, when a parameter is defined, there is a name assigned.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;param0 &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;Parameter&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; displayName&lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"Input Features"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; name&lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"in_features"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; datatype&lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"GPFeatureLayer"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; parameterType&lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"Required"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; direction&lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"Input"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&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;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;What is the "name" used for?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If I have a toolbox with say 20 things in it (Perhaps exessive, but it's just an example), if I add a parameter in the middle let's say param8, or move things around, param9 becoms param10, and 10-19 increment.&amp;nbsp; All my&amp;nbsp;&lt;/P&gt;&lt;P&gt;value_name = parameters[9].value&amp;nbsp; calls also have to change, and I have to keep track.&amp;nbsp; By index.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It would be useful to do something like parameters["in_features"] as in the above example.&amp;nbsp; But it's not possible, so what is "name" used for?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 01:24:50 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/what-is-parameter-name-used-for-in-python-toolbox/m-p/591663#M46380</guid>
      <dc:creator>LizEidsness</dc:creator>
      <dc:date>2021-12-12T01:24:50Z</dc:date>
    </item>
    <item>
      <title>Re: What is Parameter.name used for in python toolbox</title>
      <link>https://community.esri.com/t5/python-questions/what-is-parameter-name-used-for-in-python-toolbox/m-p/591664#M46381</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If a name is set for a parameter the name is available for interrogation. You could do this.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;paramName = parm0.name&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You could write a function to search for a given name and return the parameter index. See&amp;nbsp;&lt;A href="http://pro.arcgis.com/en/pro-app/arcpy/classes/parameter.htm"&gt;http://pro.arcgis.com/en/pro-app/arcpy/classes/parameter.htm&lt;/A&gt; and &lt;A href="http://pro.arcgis.com/en/pro-app/arcpy/functions/getparameter.htm"&gt;http://pro.arcgis.com/en/pro-app/arcpy/functions/getparameter.htm&lt;/A&gt; for more information.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;along the lines of:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;def getParamByName(pName):&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp; iArgCount=&lt;CODE&gt;&lt;SPAN&gt;arcpy&lt;/SPAN&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;SPAN&gt;GetArgumentCount&lt;/SPAN&gt;&lt;SPAN&gt;()&lt;/SPAN&gt;&lt;/CODE&gt;&lt;CODE&gt;&lt;/CODE&gt;&lt;/P&gt;&lt;P&gt;&lt;CODE&gt;&lt;SPAN&gt;&amp;nbsp; # Note, a pIndex of -1 indicates parameter not found&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/P&gt;&lt;P&gt;&lt;CODE&gt;&lt;SPAN&gt;&amp;nbsp; pIndex= -1&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/P&gt;&lt;P&gt;&lt;CODE&gt;&lt;SPAN&gt;&amp;nbsp; iCount=0&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; while (iCount&amp;lt;iArgCount):&lt;CODE&gt;&lt;/CODE&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; param=arcpy.GetParameter(iCount)&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if param.name==pName:&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp; pIndex=iCount&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; iCount=iCount+1&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp; return pIndex;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 07 Dec 2017 23:46:56 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/what-is-parameter-name-used-for-in-python-toolbox/m-p/591664#M46381</guid>
      <dc:creator>RichardDaniels</dc:creator>
      <dc:date>2017-12-07T23:46:56Z</dc:date>
    </item>
    <item>
      <title>Re: What is Parameter.name used for in python toolbox</title>
      <link>https://community.esri.com/t5/python-questions/what-is-parameter-name-used-for-in-python-toolbox/m-p/591665#M46382</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;So essentially, it's just an attribute of the object.&amp;nbsp; If I want to make it useful, I have to wrap my own code around it.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 12 Dec 2017 15:26:06 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/what-is-parameter-name-used-for-in-python-toolbox/m-p/591665#M46382</guid>
      <dc:creator>LizEidsness</dc:creator>
      <dc:date>2017-12-12T15:26:06Z</dc:date>
    </item>
    <item>
      <title>Re: What is Parameter.name used for in python toolbox</title>
      <link>https://community.esri.com/t5/python-questions/what-is-parameter-name-used-for-in-python-toolbox/m-p/591666#M46383</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;most likely, but in some pure python code I've seen code similar to&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;getParameter(param0.Name&lt;CODE&gt;&lt;SPAN&gt;)&amp;nbsp;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/P&gt;&lt;P&gt;&lt;CODE&gt;&lt;/CODE&gt;&lt;/P&gt;&lt;P&gt;&lt;CODE&gt;&lt;SPAN&gt; you might try arcpy.getParameter("in_features"), were in_feature is a name of a parameter, and see if it works. &lt;/SPAN&gt;&lt;/CODE&gt;&lt;/P&gt;&lt;P&gt;&lt;CODE&gt;&lt;/CODE&gt;&lt;/P&gt;&lt;P&gt;&lt;CODE&gt;&lt;SPAN&gt;If it does let us know :-)&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 12 Dec 2017 17:03:38 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/what-is-parameter-name-used-for-in-python-toolbox/m-p/591666#M46383</guid>
      <dc:creator>RichardDaniels</dc:creator>
      <dc:date>2017-12-12T17:03:38Z</dc:date>
    </item>
    <item>
      <title>Re: What is Parameter.name used for in python toolbox</title>
      <link>https://community.esri.com/t5/python-questions/what-is-parameter-name-used-for-in-python-toolbox/m-p/1259581#M66890</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;create a function that writes the parameters to a dictionary keyed with the parameter name.&lt;/P&gt;&lt;P&gt;def createparamsDict(params):&lt;/P&gt;&lt;P&gt;dictParams = {}&lt;/P&gt;&lt;P&gt;for x in range(0, len(params) - 1):&lt;BR /&gt;p = params[x]&lt;BR /&gt;dictParams[p.name] = p&lt;/P&gt;&lt;P&gt;return dictParams&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Then call that at the start of your execute function&lt;/P&gt;&lt;P&gt;paramdict = createparamsDict(parameters)&lt;/P&gt;&lt;P&gt;Then you can just refer to the parameters by thier name.&lt;/P&gt;&lt;P&gt;arcpy.AddMessage(paramdict["storm_pipes"].valueAsText)&lt;BR /&gt;arcpy.AddMessage(paramdict["storm_pipes"].datatype)&lt;/P&gt;</description>
      <pubDate>Fri, 17 Feb 2023 22:16:28 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/what-is-parameter-name-used-for-in-python-toolbox/m-p/1259581#M66890</guid>
      <dc:creator>RobertMEIER</dc:creator>
      <dc:date>2023-02-17T22:16:28Z</dc:date>
    </item>
  </channel>
</rss>

