<?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: Problems parsing SetParameterAsText in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/problems-parsing-setparameterastext/m-p/210408#M16289</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&amp;nbsp;You're setting the parameter to &lt;SPAN&gt;outputPDF which is a geoprocessing&lt;/SPAN&gt;&amp;nbsp;Result object. Set it to&amp;nbsp;outputPath instead.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 02 Nov 2018 11:03:18 GMT</pubDate>
    <dc:creator>Luke_Pinner</dc:creator>
    <dc:date>2018-11-02T11:03:18Z</dc:date>
    <item>
      <title>Problems parsing SetParameterAsText</title>
      <link>https://community.esri.com/t5/python-questions/problems-parsing-setparameterastext/m-p/210406#M16287</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I think I have all my indexing correct.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have 8 parameters in my script tool. 7 input and 1 derived output. Indexing for GetParameterAsText starts at 0, so logically my SetParameterAsText should have an index of 7, considering my output parameter is the last one in the list.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;I use sys.argv to set my input parameters in the script. This index starts at 1.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;My script:&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;&lt;SPAN class="comment token"&gt;#Get all the inputs from the user&lt;/SPAN&gt;
year &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; sys&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;argv&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;1&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt; &lt;SPAN class="comment token"&gt;#GetParameterAsText(0)&lt;/SPAN&gt;
state &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; sys&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;argv&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;2&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt; &lt;SPAN class="comment token"&gt;#GetParameterAsText(1)&lt;/SPAN&gt;
cipArea &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; sys&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;argv&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;3&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt; &lt;SPAN class="comment token"&gt;#GetParameterAsText(2)&lt;/SPAN&gt;
layerString &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; sys&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;argv&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;4&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt; &lt;SPAN class="comment token"&gt;#GetParameterAsText(3)&lt;/SPAN&gt;
renderer &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; sys&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;argv&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;5&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt; &lt;SPAN class="comment token"&gt;#GetParameterAsText(4)&lt;/SPAN&gt;
orientation &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; sys&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;argv&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;6&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt; &lt;SPAN class="comment token"&gt;#GetParameterAsText(5)&lt;/SPAN&gt;
emailAddr &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; sys&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;argv&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;7&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt; &lt;SPAN class="comment token"&gt;#GetParametersAsText(6)&lt;/SPAN&gt;

&lt;SPAN class="comment token"&gt;#Do a ton of stuff&lt;/SPAN&gt;

outputPath &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; os&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;path&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;join&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;env&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;scratchFolder&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"Map.pdf"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
outputPDF &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;mapping&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;ExportToPDF&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;mxd&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; outputPath&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;SetParameterAsText&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;7&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; outputPDF&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;/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;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;How the output parameter is set (there are 8 parameters, I just can't expand the window to show them all):&lt;/P&gt;&lt;P&gt;&lt;IMG __jive_id="426826" alt="" class="image-1 jive-image j-img-original" src="https://community.esri.com/legacyfs/online/426826_Capture.JPG" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Input window (don't mind the x's):&lt;/P&gt;&lt;P&gt;&lt;IMG alt="" class="image-2 jive-image j-img-original" src="https://community.esri.com/legacyfs/online/426876_Capture.JPG" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Anybody know what could be happening? This is the error I get back:&lt;/P&gt;&lt;BLOCKQUOTE class="jive_macro_quote jive-quote jive_text_macro"&gt;&lt;P&gt;Traceback (most recent call last):&lt;BR /&gt; File "D:\NET_Projects\HabitatMapGPServices\PrintHabitatMaps\PrintHabitatMaps.py", line 234, in &amp;lt;module&amp;gt;&lt;BR /&gt; arcpy.SetParameterAsText(7, outputPDF)&lt;BR /&gt; File "c:\program files (x86)\arcgis\desktop10.6\arcpy\arcpy\__init__.py", line 670, in SetParameterAsText&lt;BR /&gt; return gp.setParameterAsText(index, text)&lt;BR /&gt; File "c:\program files (x86)\arcgis\desktop10.6\arcpy\arcpy\geoprocessing\_base.py", line 231, in setParameterAsText&lt;BR /&gt; self._gp.SetParameterAsText(*gp_fixargs(args, True)))&lt;BR /&gt;AttributeError: Object: Error in parsing arguments for SetParameterAsText&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 10:22:45 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/problems-parsing-setparameterastext/m-p/210406#M16287</guid>
      <dc:creator>MKF62</dc:creator>
      <dc:date>2021-12-11T10:22:45Z</dc:date>
    </item>
    <item>
      <title>Re: Problems parsing SetParameterAsText</title>
      <link>https://community.esri.com/t5/python-questions/problems-parsing-setparameterastext/m-p/210407#M16288</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;So, when setting parameter as text, you have to make sure the output is actually a string. In my case it was not, so the script should look like this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="language-python line-numbers"&gt;&lt;CODE&gt;arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;SetParameterAsText&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;7&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; str&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;outputPDF&lt;SPAN class="punctuation token"&gt;)&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;/CODE&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 01 Nov 2018 14:01:51 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/problems-parsing-setparameterastext/m-p/210407#M16288</guid>
      <dc:creator>MKF62</dc:creator>
      <dc:date>2018-11-01T14:01:51Z</dc:date>
    </item>
    <item>
      <title>Re: Problems parsing SetParameterAsText</title>
      <link>https://community.esri.com/t5/python-questions/problems-parsing-setparameterastext/m-p/210408#M16289</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&amp;nbsp;You're setting the parameter to &lt;SPAN&gt;outputPDF which is a geoprocessing&lt;/SPAN&gt;&amp;nbsp;Result object. Set it to&amp;nbsp;outputPath instead.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 02 Nov 2018 11:03:18 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/problems-parsing-setparameterastext/m-p/210408#M16289</guid>
      <dc:creator>Luke_Pinner</dc:creator>
      <dc:date>2018-11-02T11:03:18Z</dc:date>
    </item>
    <item>
      <title>Re: Problems parsing SetParameterAsText</title>
      <link>https://community.esri.com/t5/python-questions/problems-parsing-setparameterastext/m-p/210409#M16290</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Makes sense, that would work just fine too.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 02 Nov 2018 12:38:31 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/problems-parsing-setparameterastext/m-p/210409#M16290</guid>
      <dc:creator>MKF62</dc:creator>
      <dc:date>2018-11-02T12:38:31Z</dc:date>
    </item>
  </channel>
</rss>

