Skip to main content

Result

Resumen

The result of a geoprocessing tool.

Debate

A Result object maintains information about a tool operation after it has completed. This includes messages, parameters, and outputs. Functions such as arcpy.GetMessages provide information solely from the preceding tool. However, you can maintain a Result object even after running other tools.

Sintaxis

Result(toolname, resultID)

Nombre Explicación Tipo de datos

toolname

The name of the tool that was run.

String

resultID

The job ID.

Integer

Propiedades

Nombre Explicación Tipo de datos

inputCount

(Solo lectura)

The number of inputs.

Integer

maxSeverity

(Solo lectura)

Specifies the maximum severity of the messages.

  • 0—The tool produced only informative messages.

  • 1—The tool produced a warning message but no error messages.

  • 2—The tool produced an error message.

Integer

messageCount

(Solo lectura)

The number of messages.

Integer

outputCount

(Solo lectura)

The number of outputs.

Integer

resultID

(Solo lectura)

The job ID. If the tool is not a geoprocessing service, the value will be "".

String

status

(Solo lectura)

Specifies the job status.

  • 0—The job status is New.

  • 1—The job status is Submitted.

  • 2—The job status is Waiting.

  • 3—The job status is Executing.

  • 4—The job status is Succeeded.

  • 5—The job status is Failed.

  • 6—The job status is Timed out.

  • 7—The job status is Cancelling.

  • 8—The job status is Cancelled.

  • 9—The job status is Deleting.

  • 10—The job status is Deleted.

Integer

Métodos

cancel()

Cancel an associated job.

getAllMessages()

Returns the message types, return codes, and message strings.

Valor de retorno

Tipo de datos Explicación

List

Returns a list of lists that includes by position: the type, return code, and message string.

The first item in each internal list is an integer representing the message type.

  • 0—Informative message

  • 1—Definition message

  • 2—Start message

  • 3—Stop message

  • 50—Warning message

  • 100—Error message

  • 101—Empty message

  • 102—Geodatabase error message

  • 200—Abort message

The second item is an integer representing the message return code. If the message has an associated ID number, the item will be ID number. Error messages that do not have an ID will return -2147467259. All other messages will return a 0. The second item is the message string.

getCharts({wildcard})

Returns chart objects created by the tool.

Nombre Explicación Tipo de datos

wildcard

(Opcional)

Limits the charts returned by title. If no value is specified, all charts are returned. The wildcard is not case sensitive.

Symbol

Description

Example

*

Represents zero or more characters.

Te* finds Tennessee and Texas.

*

Valor de retorno

Tipo de datos Explicación

Object

A list of chart objects. The type of object will vary depending on the type of chart, for example, Bar or Box.

getInput(index)

Returns a given input, either as a string or a RecordSet object.

Nombre Explicación Tipo de datos

index

The index position of the input as an integer, or the parameter name.

Variant

Valor de retorno

Tipo de datos Explicación

Variant

The input, either as a RecordSet object or a string.

getMapImageURL({parameter_list}, {height}, {width}, {resolution})

Returns a map service image for a given output, if one exists.

Nombre Explicación Tipo de datos

parameter_list

(Opcional)

The parameters on which the map service image will be based.

Integer

height

(Opcional)

The height of the image.

Double

width

(Opcional)

The width of the image.

Double

resolution

(Opcional)

The resolution of the image.

Double

Valor de retorno

Tipo de datos Explicación

String

The URL of the map image.

getMessage(index)

Returns a specific message by index position.

Nombre Explicación Tipo de datos

index

The index position of the message.

Integer

Valor de retorno

Tipo de datos Explicación

String

The geoprocessing message.

getMessages({severity})

Returns the geoprocessing tool messages.

Nombre Explicación Tipo de datos

severity

(Opcional)

The type of messages to be returned.

  • 0—Informative, warning, and error messages are returned.

  • 1—Only warning messages are returned.

  • 2—Only error messages are returned.

Not specifying a severity level will return all types of messages.

The default value is 0.

Integer

Valor de retorno

Tipo de datos Explicación

String

The geoprocessing tool messages.

getOutput(index)

Returns a given output, either as a RecordSet object or a string.

If the output of the tool, such as Make Feature Layer, is a layer, getOutput will return a Layer object.

Nombre Explicación Tipo de datos

index

The index position of the output as an integer, or the parameter name.

Variant

Valor de retorno

Tipo de datos Explicación

Variant

The output, either as a RecordSet or a string.

If the output of the tool, such as Make Feature Layer, is a layer, getOutput will return a Layer object.

Result outputs can also be accessed by index by integer or by name. For example, to access the record count from the Get Count tool, result.getOutput(0), result[0], result.getOutput("row_count"), and result["row_count"] are equivalent.

getSeverity(index)

Specifies the severity of a specific message.

Nombre Explicación Tipo de datos

index

The message index position.

Integer

Valor de retorno

Tipo de datos Explicación

Integer

The severity of the specific message.

  • 0—Informative, warning, and error messages are returned.

  • 1—Only warning messages are returned.

  • 2—Only error messages are returned.

saveToFile(rlt_file)

Saves the result to a result file.

Nota:

saveToFile is not supported in ArcGIS Pro; use the Package Result tool instead.

Nombre Explicación Tipo de datos

rlt_file

The full path to the output result file (.rlt).

String

Muestra de código

Result example 1

From a Result object returned from the Get Count tool, access the record count by index.

import arcpy

in_table = arcpy.GetParameterAsText(0)
result = arcpy.management.GetCount(in_table)
print(result[0])
Result example 2

From a Result object returned from the Get Count tool, access the record count by name.

import arcpy

in_table = arcpy.GetParameterAsText(0)
result = arcpy.management.GetCount(in_table)
print(result["row_count"])
Result example 3

The script obtains the feature set schema from a server tool, then loads data to the feature set, and passes it to the server tool. Once the tool completes, the script saves the result to a local dataset.

import time
import arcpy

# Add a toolbox from a server
arcpy.ImportToolbox("http://myserver/arcgis/services;GP/BufferByVal",
                    "servertools")

# Use GetParameterValue to get a featureset object with the default
# schema of the first parameter of the tool 'bufferpoints'
in_featureset = arcpy.GetParameterValue("bufferpoints", 0)

# Load a shapefile into the featureset
in_featureset.load("C:/Data/roads.shp")

# Run a server tool named BufferPoints with featureset created above
result = arcpy.server.BufferPoints(in_featureset, "500 feet")

# Check the status of the result object every 0.2 seconds
#    until it has a value of 4 (succeeded) or greater
while result.status < 4:
    time.sleep(0.2)

# Get the output FeatureSet back from the server and save to a local geodatabase
out_featureset = result.getOutput(0)
out_featureset.save("c:/temp/base.gdb/roads_buffer")
Result example 4

Re-create the output of a geoprocessing service using the tool name and result ID.

import arcpy

# Add the toolbox from the server
arcpy.ImportToolbox("http://myserver/arcgis/services;GP/BufferByVal")

# Recreate the original output using the tool name and result id
result_id = 'jfea96e13ba7b443cb04ba47c19899a1b'
result = arcpy.Result("BufferPoints", result_id)