AddReturnMessage

Zusammenfassung

Sets the return message of a script tool as an output message by index.

Diskussion

There are times when you may want to return all messages from a tool you've called, regardless of message severity. Using the index parameter, AddReturnMessage will return a message from the last tool executed. The severity of the message (warning, error, and so on, is preserved).

Geoprocessing error numbers shown in the progress dialog box are hyperlinks to a help page that further describes the error. To enable hyperlinks for errors in your script, use the AddReturnMessage function instead of the AddError function, as follows:

import arcpy
try:    
    result = arcpy.GetCount_management("c:/data/rivers.shp")

except:    
    # Return Geoprocessing tool specific errors
    #
    for msg in range(0, arcpy.GetMessageCount()):
        if arcpy.GetSeverity(msg) == 2:
            arcpy.AddReturnMessage(msg)

Syntax

AddReturnMessage (index)
ParameterErläuterungDatentyp
index

The message index.

Integer

Codebeispiel

AddReturnMessage example

Returns all messages from the last tool executed as script tool output messages.

import arcpy

# Set current workspace
arcpy.env.workspace = "c:/data/base.gdb"

arcpy.Buffer_analysis("roads", "roads_buffer_1000", "1000 feet")

# Return the resulting messages as script tool output messages
for i in range(0, arcpy.GetMessageCount()):
    arcpy.AddReturnMessage(i)

Verwandte Themen