<?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: error setting parameter as text in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/error-setting-parameter-as-text/m-p/509439#M40008</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Stacy, your link points to a consistent example (the same list is being referenced by both get and set).&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Index 0 = input parameter&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Index 1 = 1st output parameter&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Index 2 = 2nd output parameter&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Index 3 = 3rd output parameter&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 02 Sep 2011 21:17:28 GMT</pubDate>
    <dc:creator>DarrenWiens2</dc:creator>
    <dc:date>2011-09-02T21:17:28Z</dc:date>
    <item>
      <title>error setting parameter as text</title>
      <link>https://community.esri.com/t5/python-questions/error-setting-parameter-as-text/m-p/509435#M40004</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I've created a simple python script that creates selection criteria based on the current year.&amp;nbsp; All works fine until I try to pass the parameters as text.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;lt;type 'exceptions.RuntimeError'&amp;gt;: Object: Error in setting parameter as text&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;For the script parameters in my toolbox, I set up four parameter properties as Type = Derived, Direction = Output, Data Type = String.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;What am I doing wrong?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Code:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;import arcpy, datetime&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;currYear = datetime.datetime.today().strftime("%Y")&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;arcpy.AddMessage("Current Year = " + str(currYear))&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;# Set Local variables&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;num3YearsAgo = int(currYear) - 3&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;num4YearsAgo = int(currYear) - 4&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;num5YearsAgo = int(currYear) - 5&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;num6YearsAgo = int(currYear) - 6&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;num12YearsAgo = int(currYear) - 12&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;# Set up Selection Criteria to be passed to next step&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;strCat1 = '"Surf_Hist_Pavement_Year" &amp;gt;= ' + str(num3YearsAgo)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;strCat2 = '"Surf_Hist_Pavement_Year" &amp;gt;= ' + str(num5YearsAgo) + ' AND "Surf_Hist_Pavement_Year" &amp;lt;= ' + str(num4YearsAgo)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;strCat3 = '"Surf_Hist_Pavement_Year" &amp;gt;= ' + str(num12YearsAgo) + ' AND "Surf_Hist_Pavement_Year" &amp;lt;= ' + str(num6YearsAgo)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;strCat4 = '"Surf_Hist_Pavement_Year" &amp;lt; ' + str(num12YearsAgo)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;arcpy.AddMessage(strCat1)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;arcpy.AddMessage(strCat2)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;arcpy.AddMessage(strCat3)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;arcpy.AddMessage(strCat4)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;# Set Output parameters&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;arcpy.SetParameterAsText(1, strCat1)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;arcpy.SetParameterAsText(2, strCat2)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;arcpy.SetParameterAsText(3, strCat3)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;arcpy.SetParameterAsText(4, strCat4)&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 01 Sep 2011 20:55:25 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/error-setting-parameter-as-text/m-p/509435#M40004</guid>
      <dc:creator>LoriEmerson_McCormack</dc:creator>
      <dc:date>2011-09-01T20:55:25Z</dc:date>
    </item>
    <item>
      <title>Re: error setting parameter as text</title>
      <link>https://community.esri.com/t5/python-questions/error-setting-parameter-as-text/m-p/509436#M40005</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Yo, just played around with this; despite what the documentation says, the indexes for your output parameters need to start at 0... In your previous code it was only the last &lt;/SPAN&gt;&lt;STRONG&gt;SetParameterAsText&lt;/STRONG&gt;&lt;SPAN&gt; that actually fails. It works for me if I do this:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;import arcpy, datetime

currYear = datetime.datetime.today().strftime("%Y")
arcpy.AddMessage("Current Year = " + str(currYear))


# Set Local variables
num3YearsAgo = int(currYear) - 3
num4YearsAgo = int(currYear) - 4
num5YearsAgo = int(currYear) - 5
num6YearsAgo = int(currYear) - 6
num12YearsAgo = int(currYear) - 12

# Set up Selection Criteria to be passed to next step
strCat1 = '"Surf_Hist_Pavement_Year" &amp;gt;= ' + str(num3YearsAgo)
strCat2 = '"Surf_Hist_Pavement_Year" &amp;gt;= ' + str(num5YearsAgo) + ' AND "Surf_Hist_Pavement_Year" &amp;lt;= ' + str(num4YearsAgo)
strCat3 = '"Surf_Hist_Pavement_Year" &amp;gt;= ' + str(num12YearsAgo) + ' AND "Surf_Hist_Pavement_Year" &amp;lt;= ' + str(num6YearsAgo)
strCat4 = '"Surf_Hist_Pavement_Year" &amp;lt; ' + str(num12YearsAgo)


arcpy.AddMessage(strCat1)
arcpy.AddMessage(strCat2)
arcpy.AddMessage(strCat3)
arcpy.AddMessage(strCat4)

# Set Output parameters
arcpy.SetParameterAsText(0, strCat1)
arcpy.SetParameterAsText(1, strCat2)
arcpy.SetParameterAsText(2, strCat3)
arcpy.SetParameterAsText(3, strCat4)&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Let me know how you get on.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 22:19:11 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/error-setting-parameter-as-text/m-p/509436#M40005</guid>
      <dc:creator>StacyRendall1</dc:creator>
      <dc:date>2021-12-11T22:19:11Z</dc:date>
    </item>
    <item>
      <title>Re: error setting parameter as text</title>
      <link>https://community.esri.com/t5/python-questions/error-setting-parameter-as-text/m-p/509437#M40006</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Worked like a charm.&amp;nbsp; Thanks!&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The other code samples I looked at all had an input parameter which is why their output started with an index of 1 instead of 0.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 02 Sep 2011 15:06:41 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/error-setting-parameter-as-text/m-p/509437#M40006</guid>
      <dc:creator>LoriEmerson_McCormack</dc:creator>
      <dc:date>2011-09-02T15:06:41Z</dc:date>
    </item>
    <item>
      <title>Re: error setting parameter as text</title>
      <link>https://community.esri.com/t5/python-questions/error-setting-parameter-as-text/m-p/509438#M40007</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I meant the actual ESRI documentation...&lt;/SPAN&gt;&lt;BR /&gt;&lt;A href="http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#//000v00000019000000"&gt;http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#//000v00000019000000&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;It is usual for Pyhton indexes to start at 0, which is why I gave it a shot, but ESRI ought to at least be consistent between get and set!&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 02 Sep 2011 20:31:07 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/error-setting-parameter-as-text/m-p/509438#M40007</guid>
      <dc:creator>StacyRendall1</dc:creator>
      <dc:date>2011-09-02T20:31:07Z</dc:date>
    </item>
    <item>
      <title>Re: error setting parameter as text</title>
      <link>https://community.esri.com/t5/python-questions/error-setting-parameter-as-text/m-p/509439#M40008</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Stacy, your link points to a consistent example (the same list is being referenced by both get and set).&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Index 0 = input parameter&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Index 1 = 1st output parameter&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Index 2 = 2nd output parameter&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Index 3 = 3rd output parameter&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 02 Sep 2011 21:17:28 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/error-setting-parameter-as-text/m-p/509439#M40008</guid>
      <dc:creator>DarrenWiens2</dc:creator>
      <dc:date>2011-09-02T21:17:28Z</dc:date>
    </item>
    <item>
      <title>Re: error setting parameter as text</title>
      <link>https://community.esri.com/t5/python-questions/error-setting-parameter-as-text/m-p/509440#M40009</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Excellent!&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 03 Sep 2011 01:18:16 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/error-setting-parameter-as-text/m-p/509440#M40009</guid>
      <dc:creator>StacyRendall1</dc:creator>
      <dc:date>2011-09-03T01:18:16Z</dc:date>
    </item>
    <item>
      <title>Re: error setting parameter as text</title>
      <link>https://community.esri.com/t5/python-questions/error-setting-parameter-as-text/m-p/509441#M40010</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi all&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm trying to use your script as an example for myself to try work out how to parse the SetParameterAsText results to a model's parameters. Your script works and runs but I simply cannot get the results into a subsequent model's parameters. I have tried looking for a clear example online that shows the entire process of setting the parameter text and then using it, but I simply don't know where to 'put' the parameter text. I'm sure it is quite simple, but I'm just not seeing it. Presently I've done your script, placed it into ArcGIS scripts with the parameters parsed into the ArcGIS, as per the example image below. However, now what do I do to place the derived output into the 'next' model/script?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Nigel&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG alt="Set Parameter as Text example" class="image-1 jive-image j-img-original" src="https://community.esri.com/legacyfs/online/350247_SetParameterAsText.jpg" style="width: 620px; height: 322px;" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 09 May 2017 12:05:09 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/error-setting-parameter-as-text/m-p/509441#M40010</guid>
      <dc:creator>NigelBerjak</dc:creator>
      <dc:date>2017-05-09T12:05:09Z</dc:date>
    </item>
  </channel>
</rss>

