<?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: Geoprocessing Service shows always same output value in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/geoprocessing-service-shows-always-same-output/m-p/333163#M25954</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Set the output parameter? &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="python" __jive_macro_name="code" class="jive_macro_code _jivemacro_uid_1454085764582517 jive_text_macro" data-renderedposition="50_8_912_16" jivemacro_uid="_1454085764582517"&gt;&lt;P&gt;arcpy.SetParameterAsText(1, Scale)&lt;/P&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 29 Jan 2016 16:43:10 GMT</pubDate>
    <dc:creator>JamesCrandall</dc:creator>
    <dc:date>2016-01-29T16:43:10Z</dc:date>
    <item>
      <title>Geoprocessing Service shows always same output value</title>
      <link>https://community.esri.com/t5/python-questions/geoprocessing-service-shows-always-same-output/m-p/333162#M25953</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi, I need to know the scale of an mxd in a web application. For that I am running&amp;nbsp; a geoprocessing service. I need to know the scale when there is a definition query and the map zooms in to that feature. I can see in the message that the scale changes, but the output in the web application is always the same scale, although the input feature changes. What am I doing wrong? Thank you for any help.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;import arcpy&lt;/P&gt;&lt;P&gt;import os&lt;/P&gt;&lt;P&gt;import uuid&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;# Input Layout template&lt;/P&gt;&lt;P&gt;Layout_Template = arcpy.GetParameterAsText(0)&lt;/P&gt;&lt;P&gt;if Layout_Template == '#' or not Layout_Template:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Layout_Template = "StewardshipTractBoundaryMap" &lt;/P&gt;&lt;P&gt;layouttemplatemxd = Layout_Template&lt;/P&gt;&lt;P&gt;templatePath = 'D:/ArcGISData/Geoprocessing_Examples/Advanced_HighQualityPrinting3'&lt;/P&gt;&lt;P&gt;Selecting_Features = arcpy.GetParameterAsText(1)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Input_Polygons = "Stewardship"&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;mxd0 = arcpy.mapping.MapDocument(r"D:\ArcGISData\Geoprocessing_Examples\Advanced_HighQualityPrinting3\\" + layouttemplatemxd + ".mxd")&lt;/P&gt;&lt;P&gt;df1 = arcpy.mapping.ListDataFrames(mxd0, "DataFrame1")[0]&lt;/P&gt;&lt;P&gt;mxd0.activeView = df1&lt;/P&gt;&lt;P&gt;lyr1 = arcpy.mapping.ListLayers(mxd0, Input_Polygons, df1)[0]&lt;/P&gt;&lt;P&gt;lyr1.definitionQuery = ""&lt;/P&gt;&lt;P&gt;lyr1.definitionQuery = '"PlanID" = \'%s\'' % Selecting_Features&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;df1.panToExtent(lyr1.getSelectedExtent())&lt;/P&gt;&lt;P&gt;lyr1.getExtent()&lt;/P&gt;&lt;P&gt;lyr1extent = lyr1.getExtent()&lt;/P&gt;&lt;P&gt;df1.extent = lyr1extent&lt;/P&gt;&lt;P&gt;Scale = str(df1.scale)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;arcpy.RefreshTOC()&lt;/P&gt;&lt;P&gt;arcpy.RefreshActiveView()&lt;/P&gt;&lt;P&gt;mxd0.save()&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;arcpy.SetParameterAsText(2, Scale)&lt;/P&gt;&lt;P&gt;lyr1.definitionQuery = ""&lt;/P&gt;&lt;P&gt;arcpy.RefreshTOC() &lt;/P&gt;&lt;P&gt;arcpy.RefreshActiveView()&amp;nbsp; &lt;/P&gt;&lt;P&gt;arcpy.AddMessage(Scale)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;mxd0.save()&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;del mxd0, df1, lyr1&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 29 Jan 2016 16:40:54 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/geoprocessing-service-shows-always-same-output/m-p/333162#M25953</guid>
      <dc:creator>ionarawilson</dc:creator>
      <dc:date>2016-01-29T16:40:54Z</dc:date>
    </item>
    <item>
      <title>Re: Geoprocessing Service shows always same output value</title>
      <link>https://community.esri.com/t5/python-questions/geoprocessing-service-shows-always-same-output/m-p/333163#M25954</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Set the output parameter? &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="python" __jive_macro_name="code" class="jive_macro_code _jivemacro_uid_1454085764582517 jive_text_macro" data-renderedposition="50_8_912_16" jivemacro_uid="_1454085764582517"&gt;&lt;P&gt;arcpy.SetParameterAsText(1, Scale)&lt;/P&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 29 Jan 2016 16:43:10 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/geoprocessing-service-shows-always-same-output/m-p/333163#M25954</guid>
      <dc:creator>JamesCrandall</dc:creator>
      <dc:date>2016-01-29T16:43:10Z</dc:date>
    </item>
    <item>
      <title>Re: Geoprocessing Service shows always same output value</title>
      <link>https://community.esri.com/t5/python-questions/geoprocessing-service-shows-always-same-output/m-p/333164#M25955</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;But since I have :&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Layout_Template = arcpy.GetParameterAsText(0)&lt;/P&gt;&lt;P&gt;Selecting_Features = arcpy.GetParameterAsText(1)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Shouldn't it be arcpy.SetParameterAsText(2, Scale) like it is now?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 29 Jan 2016 16:58:36 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/geoprocessing-service-shows-always-same-output/m-p/333164#M25955</guid>
      <dc:creator>ionarawilson</dc:creator>
      <dc:date>2016-01-29T16:58:36Z</dc:date>
    </item>
    <item>
      <title>Re: Geoprocessing Service shows always same output value</title>
      <link>https://community.esri.com/t5/python-questions/geoprocessing-service-shows-always-same-output/m-p/333165#M25956</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I suppose if that is the second output parameter.&amp;nbsp; I didn't notice the first output parameter in the code sample you posted.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Also: do you get any output result when you execute the task from the services url?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 29 Jan 2016 18:13:55 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/geoprocessing-service-shows-always-same-output/m-p/333165#M25956</guid>
      <dc:creator>JamesCrandall</dc:creator>
      <dc:date>2016-01-29T18:13:55Z</dc:date>
    </item>
    <item>
      <title>Re: Geoprocessing Service shows always same output value</title>
      <link>https://community.esri.com/t5/python-questions/geoprocessing-service-shows-always-same-output/m-p/333166#M25957</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;No, there is only one output parameter, but I thought the input and output parameters shared indexes, no? So, even thought it is the first output parameter, it should have an index of 2, not of 0, because there are two input parameters. This example shows that the output parameter is indexed as 1 because there is a input parameter first.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="http://pro.arcgis.com/en/pro-app/arcpy/functions/setparameterastext.htm" title="http://pro.arcgis.com/en/pro-app/arcpy/functions/setparameterastext.htm"&gt;SetParameterAsText—ArcPy Functions | ArcGIS for Desktop&lt;/A&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 29 Jan 2016 18:24:15 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/geoprocessing-service-shows-always-same-output/m-p/333166#M25957</guid>
      <dc:creator>ionarawilson</dc:creator>
      <dc:date>2016-01-29T18:24:15Z</dc:date>
    </item>
    <item>
      <title>Re: Geoprocessing Service shows always same output value</title>
      <link>https://community.esri.com/t5/python-questions/geoprocessing-service-shows-always-same-output/m-p/333167#M25958</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Perhaps I'm misunderstanding it myself but I read it as this being the index of the output parameters only.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In any case, if there's only one output, set it to 1 like I showed!&amp;nbsp; &lt;IMG src="https://community.esri.com/legacyfs/online/emoticons/happy.png" /&gt;&amp;nbsp; --- in looking at my own codebase, the only example I have is where I am setting a single output parameter not a list of them.&amp;nbsp; This returns a JSON output string that is the result of some geoprocessing:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;&lt;P&gt;arcpy.SetParameterAsText(1, json.dumps(data))&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/BLOCKQUOTE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 29 Jan 2016 18:31:16 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/geoprocessing-service-shows-always-same-output/m-p/333167#M25958</guid>
      <dc:creator>JamesCrandall</dc:creator>
      <dc:date>2016-01-29T18:31:16Z</dc:date>
    </item>
    <item>
      <title>Re: Geoprocessing Service shows always same output value</title>
      <link>https://community.esri.com/t5/python-questions/geoprocessing-service-shows-always-same-output/m-p/333168#M25959</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;How many inputs do you have on this example? &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 29 Jan 2016 18:46:08 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/geoprocessing-service-shows-always-same-output/m-p/333168#M25959</guid>
      <dc:creator>ionarawilson</dc:creator>
      <dc:date>2016-01-29T18:46:08Z</dc:date>
    </item>
    <item>
      <title>Re: Geoprocessing Service shows always same output value</title>
      <link>https://community.esri.com/t5/python-questions/geoprocessing-service-shows-always-same-output/m-p/333169#M25960</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;1 &lt;IMG src="https://community.esri.com/legacyfs/online/emoticons/happy.png" /&gt;&amp;nbsp; LOL!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 29 Jan 2016 19:08:17 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/geoprocessing-service-shows-always-same-output/m-p/333169#M25960</guid>
      <dc:creator>JamesCrandall</dc:creator>
      <dc:date>2016-01-29T19:08:17Z</dc:date>
    </item>
    <item>
      <title>Re: Geoprocessing Service shows always same output value</title>
      <link>https://community.esri.com/t5/python-questions/geoprocessing-service-shows-always-same-output/m-p/333170#M25961</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Then that explains why your gp works, if you have one input parameter its index should be 0 and if you also have an output parameter then the index should be 1, because they share index values. But I will try your approach, although I dont think it is going to fix the problem. Thank you&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 29 Jan 2016 19:36:03 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/geoprocessing-service-shows-always-same-output/m-p/333170#M25961</guid>
      <dc:creator>ionarawilson</dc:creator>
      <dc:date>2016-01-29T19:36:03Z</dc:date>
    </item>
    <item>
      <title>Re: Geoprocessing Service shows always same output value</title>
      <link>https://community.esri.com/t5/python-questions/geoprocessing-service-shows-always-same-output/m-p/333171#M25962</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Sorry I don't have an immediate answer.&amp;nbsp; I'd love to hear what you find out though as I'm sure I will run into the requirement of multiple params for a geop service at some point.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 29 Jan 2016 19:41:50 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/geoprocessing-service-shows-always-same-output/m-p/333171#M25962</guid>
      <dc:creator>JamesCrandall</dc:creator>
      <dc:date>2016-01-29T19:41:50Z</dc:date>
    </item>
    <item>
      <title>Re: Geoprocessing Service shows always same output value</title>
      <link>https://community.esri.com/t5/python-questions/geoprocessing-service-shows-always-same-output/m-p/333172#M25963</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I like sys.argv although others prefer getparameterastext&lt;/P&gt;&lt;P&gt;sys.argv[0]&amp;nbsp; is always the script name&lt;/P&gt;&lt;P&gt;sys.argv[1] ... sys.argv&lt;N&gt;&amp;nbsp; are the number of parameters that you specify in sequential order, so if you have 2 input parameters and 1 output parameter, then they would be numbered, 1,2,3&lt;/N&gt;&lt;/P&gt;&lt;P&gt;I am sure get...astext works the same way, but it starts at 0 since it doesn't know the script name.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 29 Jan 2016 22:11:49 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/geoprocessing-service-shows-always-same-output/m-p/333172#M25963</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2016-01-29T22:11:49Z</dc:date>
    </item>
    <item>
      <title>Re: Geoprocessing Service shows always same output value</title>
      <link>https://community.esri.com/t5/python-questions/geoprocessing-service-shows-always-same-output/m-p/333173#M25964</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If the tool works as a regular tool before publishing, but not as a service, your parameter index are probably correct.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;My guess is when publishing it hasn't updated, or incorrectly updated the paths to either the templates, or the selected features you're passing in isn't working correctly.&lt;/P&gt;&lt;P&gt;The first and easiest test is to consume the service back in ArcMap - ArcMap will always pass the features correctly. If you get the correct result there, but not the webapp, its something to do with how the service + web application is setup. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If that isn't the problem, I'd try changing your first bit of code&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;import os&lt;/STRONG&gt;&lt;/P&gt;&lt;P style="font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif;"&gt;&lt;STRONG&gt;layouttemplatemxd = arcpy.GetParameterAsText(0) if arcpy.GetParameterAsText(0) else "StewardshipTractBoundaryMap"&amp;nbsp; #I think this should work&lt;/STRONG&gt;&lt;/P&gt;&lt;P style="font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif;"&gt;&lt;SPAN style="text-decoration: line-through;"&gt;L&lt;/SPAN&gt;&lt;SPAN style="text-decoration: line-through; line-height: 1.5;"&gt;ayout_Template = arcpy.GetParameterAsText(0)&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif;"&gt;&lt;SPAN style="text-decoration: line-through;"&gt;if Layout_Template == '#' or not Layout_Template:&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif;"&gt;&lt;SPAN style="text-decoration: line-through;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Layout_Template = "StewardshipTractBoundaryMap"&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif;"&gt;&lt;SPAN style="text-decoration: line-through;"&gt;layouttemplatemxd = Layout_Template&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif;"&gt;templatePath = 'D:/ArcGISData/Geoprocessing_Examples/Advanced_HighQualityPrinting3'&lt;/P&gt;&lt;P style="font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif;"&gt;Selecting_Features = arcpy.GetParameterAsText(1)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif;"&gt;Input_Polygons = "Stewardship"&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif;"&gt;&lt;STRONG&gt;mxd0 = &lt;SPAN style="font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif;"&gt;arcpy.mapping.MapDocument(os.path.join(&lt;SPAN style="font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif;"&gt;templatePath, &lt;SPAN style="font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif;"&gt;layouttemplatemxd + '.mxd')&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P style="font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif;"&gt;&lt;/P&gt;&lt;P style="font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif;"&gt;&lt;SPAN style="font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif;"&gt;And if none of that does it, it might be how you're doing the select itself. It looks a little strange to me&lt;/SPAN&gt;, setting the definition query then doing a select. Is that needed?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 01 Feb 2016 14:22:08 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/geoprocessing-service-shows-always-same-output/m-p/333173#M25964</guid>
      <dc:creator>KevinHibma</dc:creator>
      <dc:date>2016-02-01T14:22:08Z</dc:date>
    </item>
    <item>
      <title>Re: Geoprocessing Service shows always same output value</title>
      <link>https://community.esri.com/t5/python-questions/geoprocessing-service-shows-always-same-output/m-p/333174#M25965</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you Kevin. The gp gives the correct result in ArcMap so I am guessing is something in the web app. However, when I debug the web app it shows the selected features varies as the input but the output is always the same. I need to investigate more why this is happening in the web app. I will post the code here later. Thanks again.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 01 Feb 2016 15:01:48 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/geoprocessing-service-shows-always-same-output/m-p/333174#M25965</guid>
      <dc:creator>ionarawilson</dc:creator>
      <dc:date>2016-02-01T15:01:48Z</dc:date>
    </item>
  </channel>
</rss>

