2

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
 MyTools()
 firstFunction(table)
 secondFunction(param01)
asked Aug 12, 2019 at 13:32
3
  • 1
    Is this a true copy/paste? I see an extra comma (,) in your param01 in the datatype = "long" line. Commented Aug 12, 2019 at 14:01
  • @KHibma the extra comma is just a mistake on my part - Commented Aug 12, 2019 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. Commented Aug 12, 2019 at 22:30

1 Answer 1

1

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.

answered Aug 14, 2019 at 15:05

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.