I can't get the parameters of my tool to show up in ArcGIS Pro 2.1 Because of my work I can't put my exact code here, but I'll put the skeleton of what I'm doing and hopefully someone can see what I'm doing wrong.

As a disclaimer, I know I can right click and add the parameters directly into my script tool, through pro directly, but I want to do it strictly through python so that I can add my own error messages. However, my python skills are not the strongest and I don't see where I am going wrong.

import arcpy 

class Toolbox(object):
    def __init__(self):
        self.label = "My label"
        self.alias = "The alias"
        self.description = "The description of the tool"
        self.tools = [MyTools]

# Functions

def firstFunction(table):
    """function stuff here"""
def secondFunction(param01):
    """function stuff here"""

# Parameter Info

class MyTools(object):

    def __init__(self):
        self.label = "test"
        self.description = "The description of the tool"
        self.canRunInBackground = True

    def getParameterInfo(self):
        table = arcpy.Parameter(
            displayName = "TABLE",
            name = "table",
            datatype = ["Table", "Feature Layer"],
            parameterType = "Required",
            direction = "input")
        param01 = arcpy.Parameter(
            displayName = "param01",
            name = "param01",
            datatype = "Long", 
            parameterType = "Required",
            direction = "input")
        parameters = [table, param01]
        return parameters 

    def execute(self, parameters):
        table = parameters[0].valueAsText
        param01 = parameters[1].valueAsText

  • 1
    Is this a true copy/paste? I see an extra comma (,) in your param01 in the datatype = "long" line. – KHibma Aug 12 '19 at 14:01
  • @KHibma the extra comma is just a mistake on my part - – Renée Aug 12 '19 at 14:05
  • Your code is not conforming to the python toolbox template, suggest you look at the help page "The Python toolbox template" in the help file and you can see that your declaration of tools in the toolbox class is incorrect. – Hornbydd Aug 12 '19 at 22:30

The solution turned out to be that I was trying to run the script from a py file inside a toolbox that I created, and not as a saved pyt file.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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