GetParameterAsText (arcpy)

Resumen

Gets the specified parameter as a text string by its index position from the list of parameters.

Debate

Any value regardless of the parameter data type will be returned as a string; to use the parameter as an ArcPy or Python object instead, see GetParameter.

Sintaxis

GetParameterAsText (index)
ParámetroExplicaciónTipo de datos
index

The numeric position of the parameter in the parameter list.

Integer
Valor de retorno
Tipo de datosExplicación
String

The value of the specified parameter, returned as a string.

Ejemplo de código

GetParameterAsText example

Get specified parameter as text string.

import os
import arcpy

# Set the input workspace, get the feature class name to copy
#  and the output location.
arcpy.env.workspace = arcpy.GetParameterAsText(0)
in_featureclass = arcpy.GetParameterAsText(1)
out_workspace = arcpy.GetParameterAsText(2)

out_featureclass = os.path.join(out_workspace,
                                os.path.basename(in_featureclass))

# Copy feature class to output location
arcpy.CopyFeatures_management(in_featureclass, out_featureclass)

Temas relacionados

4/26/2014