Friday 2 August 2019

Using ArcPy Result object associated with Currently Running Script


We are at the end of a Python script using ArcPy. We can crawl around ArcPy to get information, but is there any way to get a result object for our currently running script?



My motivation is to use existing code to process the same result object we might get from executing a separate script tool earlier in the script.


To clarify, I want this object: http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#/Result/000v000000n7000000/


I was wishing I could get a Result object for the currently running process. Here are my notes for accessing ArcPy instead:


#Result.inputCount and Result.outputCount
outParameters = []
inParameters = []
for parameter in arcpy.GetParameterInfo:
if parameter.direction == "Input": #unsure of exact string
inParameters.append(parameter)
else:

outParameters.append(parameter

inputCount = len(inParameters)
outputCount = len(outParameters)

#Result.MaxSeverity
maxSeverity = arcpy.GetMaxSeverity()

#Result.MessageCount
messageCount = arcpy.GetMessageCount()


Answer



The result object isn't even constructed until the tool has finished running. You should have access to all your parameter values as variables from within the script, so there is no need for a result object.


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...