Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

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()
share|improve this question
    
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? –  theJones Nov 2 '11 at 18:13
    
Thanks for your response, I clarified my question. –  majgis Nov 4 '11 at 3:48
    
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? –  blah238 Nov 4 '11 at 4:00
    
Just mapping attributes of Result object to ArcPy object...just notes. –  majgis Nov 10 '11 at 7:05

2 Answers 2

up vote 2 down vote accepted

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.

share|improve this answer

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 Model Builder 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.)

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.