Wednesday 24 October 2018

arcpy - Why are results from Python tool not in Results window?


I am relatively new to ArcPy 10. and I want to return the list of feature class from a dataset. I can see them through the message, but cannot see them from the result window. Actually there are only inputs, environments and messages I can view from the results window. Am I missing something in the script? Thanks.


    import arcpy

import json
from arcpy import env
env.workspace=r"C:\sde\pan18.sde"
featureDatasets = arcpy.ListDatasets("SDE.POINT_OF_INTEREST")
fd=featureDatasets[0];
fcList=arcpy.ListFeatureClasses("*", "ALL", fd)
pf=[]
for fc in fcList:
pf.append(fc)
arcpy.AddMessage("--------Encode the list to a json string-\n")

layerlistEncode=json.dumps({'resource':pf})
print layerlistEncode
arcpy.AddMessage("--------Encode the json string to a list\n")
layerlistDecode=json.loads(layerlistEncode)
print layerlistDecode
print layerlistDecode["resource"]
arcpy.SetParameterAsText(0, layerlistEncode)

arcpy.AddMessage(layerlistEncode)
arcpy.AddMessage("finished1")


Edit / Delete Edit Post Reply With Quote Reply With Quote Multi-Quote This Message Top Bottom

Answer



You need to set up a derived, output parameter for SetParameterAsText to have any effect. See the help on Setting script tool parameters.


Image


No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...