Accessing parameters within a Python toolbox

Within a Python toolbox, the main body of the tool is found in the execute method. This is where any analysis, conversion, and data creation occurs. Within the execute method you can call other tools and access ArcPy or other custom or third-party Python functionality.

The execute method itself has arguments to assist in dealing with parameters and messages, including a list of parameter objects and a messages object.

def execute(self, parameters, messages):

Within the execute method, each parameter's value can be accessed from the list using the valueAsText method. Other Parameter object properties can be accessed as needed.

Access parameter values using the parameter's object valueAsText method:

def execute(self, parameters, messages):
    inFeatures      = parameters[0].valueAsText
    outFeatureClass = parameters[1].valueAsText

Related topics