1

I am creating a python toolbox within ArcGIS 10.3 and I am having issues opening it up in ArcMap. I have been editing it, saving it, and running it within ArcMap this whole time to test it little by little, and now when I double click on the tool within the toolbox it won't respond. I checked to make sure that I do not have multiple scripts running, or that I am not hiding the pop up window for the tool behind other things open on my screen. This leads me to believe that there is something wrong with my python script (below).

import arcpy


class Toolbox(object):
    def __init__(self):
        """Define the toolbox (the name of the toolbox is the name of the
        .pyt file)."""
        self.label = "Toolbox Label Property"
        self.alias = "Toolbox Alias Property"

        # List of tool classes associated with this toolbox
        self.tools = [WiFi_Buffer]


class WiFi_Buffer(object):
    def __init__(self):
        """Define the tool (tool name is the name of the class)."""
        self.label = "Buffer WAP"
        self.description = "This python script tool will buffer WAPs"
        self.canRunInBackground = False

    def getParameterInfo(self):
        """Define parameter definitions"""
        param0 = arcpy.Parameter(
        displayName="Wireless Access Points",
        name="wap_pts",
        datatype="GPFeatureLayer",
        parameterType="Required",
        direction="Input")

        param1 = arcpy.Parameter(
        displayName="Obstruction Layer",
        name="obstructions",
        datatype="GPFeatureLayer",
        parameterType="Required",
        direction="Input")

        params = [param0, param1]
        return [params]

##    def isLicensed(self):
##        """Set whether tool is licensed to execute."""
##        return True
##
##    def updateParameters(self, parameters):
##        """Modify the values and properties of parameters before internal
##        validation is performed.  This method is called whenever a parameter
##        has been changed."""
##        return
##
##    def updateMessages(self, parameters):
##        """Modify the messages created by internal validation for each tool
##        parameter.  This method is called after internal validation."""
##        return
##
##    def execute(self, parameters, messages):
##        """The source code of the tool."""
##        return

I have left the parts that I have not reached yet commented out, and it has been running the first parameter just fine, it wasn't until trying to create the second parameter (param1) that the tool wouldn't run. I don't see anything wrong with the code, but I am new to building python tools so there could be something obviously wrong with it. Any ideas on how I can get the tool to run again?

  • It probably isn't recognizing it as a proper PYT because you have the methods it is looking for commented out. Try un-commenting them. – crmackey Jul 24 '15 at 15:56
  • Try restarting ArcMap. – Barbarossa Jul 24 '15 at 16:03
  • Tried both of those, neither worked.. – Cameron Sloan Jul 24 '15 at 16:08
  • This appears to be a Python Toolbox question and does not involve a Python Script Tool so I am removing the latter tag. – PolyGeo Jul 24 '15 at 18:58
2

I figured it out. Rather than setting up a new variable "params" and holding the multiple parameters to be returned through that, I just simplified it to return the parameters directly as shown below.

    return [param0, param1]

Now it loads the tool up when clicked on with both of the parameters correctly displayed. I guess it's best to keep it simple sometimes. Thanks for the input all.

  • 1
    Thanks for sharing your solution. The reason your original code didn't work isn't because you were trying to store the parameters in a list and return it, but because you were returning that stored list inside of a list itself (ie return [params] should have been return params). – Evil Genius Jul 24 '15 at 17:05

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.