AnsweredAssumed Answered

ArcGIS 10.3.x Python tool script - Automatically adding multivalue output feature class to display

Question asked by ftonini_msugis on Jun 23, 2016
Latest reply on Jun 23, 2016 by Dan_Patterson

I am developing a Python tool script in ArcGIS 10.3.x that is meant to be later published as a GP service and consumed inside a web application (e.g. built with ESRI JS API). The tool script produces two output feature classes (see below) that I would like to automatically add to the display. Usually one would set the tool output to derived in order to accomplish that. In my tool properties, I have a derived output parameter, set to multivalue to accommodate multiple feature classes that are created in the script. However, once the script is done running, none of the two output feature classes (correctly written to my scratch GDB) show up in the TOC in ArcMap, which would be necessary before publishing it as a GP service. Anyone has an idea what am I doing wrong?

 

Code Example:

============

 

import arcpy
import os

inTable
= arcpy.GetParameterAsText(1)
startX_field
= arcpy.GetParameterAsText(2)
startY_field
= arcpy.GetParameterAsText(3)
endX_field
= arcpy.GetParameterAsText(4)
endY_field
= arcpy.GetParameterAsText(5)
lineType_str
= arcpy.GetParameterAsText(6)
SpRef = arcpy.GetParameterAsText(7)

outList
= []

# XY To Line
flowsOutputFC
= os.path.join(arcpy.env.scratchGDB, "FlowLines")

arcpy
.XYToLine_management(in_table=inTable, out_featureclass=flowsOutputFC,
                          startx_field
=startX_field, starty_field=startY_field,
                          endx_field
=endX_field, endy_field=endY_field,
                          line_type
=lineType_str, spatial_reference=SpRef)

outList
.append(flowsOutputFC)

nodesOutput
= "DestNodes"
arcpy
.MakeXYEventLayer_management(table=inTable, in_x_field=endX_field,

                                  in_y_field=endY_field, out_layer=nodesOutput)

 

nodesOutputFC = os.path.join(arcpy.env.scratchGDB, "DestNodesFC")
arcpy
.CopyFeatures_management(in_features=nodesOutput, out_feature_class=nodesOutputFC)
outList
.append(nodesOutputFC)

results
= ";".join(outList)
arcpy
.SetParameterAsText(8, results)

Outcomes