2

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()
PolyGeo
65.5k29 gold badges115 silver badges349 bronze badges
asked Nov 2, 2011 at 13:12
3
  • I am not sure if I follow. Look into os.spawnv and see if its on the right path. If not can you post a bit more info? Commented Nov 2, 2011 at 18:13
  • What is the purpose of the code you posted? Why not just design your script tool(s) to output the desired results using SetParameter or SetParameterAsText? Commented Nov 4, 2011 at 4:00
  • Just mapping attributes of Result object to ArcPy object...just notes. Commented Nov 10, 2011 at 7:05

2 Answers 2

3

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.

answered Nov 8, 2011 at 15:17
3

As alluded to by blah238 in the comments, I would recommend packaging your scripts as tools in an ArcGIS toolbox, using arcpy.SetParameter()/arcpy.SetParameterAsText() in the script whose output you wish to store the path to, and then arcpy.GetParameter()/arcpy.GetParameterAsText() in the script that you use to process that output further.

The two scripts can then be combined in a ModelBuilder model with the output of the parameter of the first serving as the input for the second. (Obviously, make sure that you actually set the type of input and output parameters within the script/tool settings, once you have them loaded into a toolbox.)

PolyGeo
65.5k29 gold badges115 silver badges349 bronze badges
answered Nov 4, 2011 at 4:17

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.