This should be so simple, I feel, but I cannot get it to work. The issue I'm having right now is making a feature layer in this python toolbox. When I try to create boxLayer I consistently get an error that the input is not supported or does not exist. I would like it to create a feature layer based on the name and number of the box requested in the tool's parameters. There are a couple of other mistakes here, but this one issue is the one I really need solved. Is there a better way to pass the box number parameter to help make a feature layer of that particular box?
class Toolbox(object):
def __init__(self):
"""Define the toolbox (the name of the toolbox is the name of the
.pyt file)."""
self.label = "Fire Department Tools"
self.alias = "fdept"
# List of tool classes associated with this toolbox
self.tools = [BoxBldgCount]
class BoxBldgCount(object):
def __init__(self):
"""Define the tool (tool name is the name of the class)."""
self.label = "Box Zone Building Count"
self.description = "The user will enter a box number and a
building type." + \
" The tool will add a field and store the building count for
the
selected type."
self.canRunInBackground = False
This is where I'm setting the parameters
def getParameterInfo(self):
"""Define parameter definitions"""
param0 = arcpy.Parameter(
displayName = "Enter the box number",
name = "inBox",
datatype = "GPLong",
parameterType = "Required",
direction = "Input")
param1 = arcpy.Parameter(
displayName = "Select a building type",
name = "bldgType",
datatype = "GPString",
parameterType = "Required",
direction = "Input")
param1.filter.type = "ValueList"
param1.filter.list = ["Single Family","Multi-Family","Commercial","Industrial",\
"City Property","Storage Sheds","Schools","Church"]
params = [param0,param1]
return params
boxNumber = parameters[0]
buildingType = parameters[1]
# Make feature layers from the user input.
And this is where I'm having the error. Why does that input not create the layer by concatenating the box number to the FireBoxMap? For example, FireBoxMap_202 exists in the geodatabase, but when I enter 202 as input I receive an error.
boxLayer = arcpy.MakeFeatureLayer_management(r"C:\EsriPress
\GISTPython\Data\City of Oleander.gdb\FireBoxMaps\FireBoxMap_"
+ str(boxNumber), "layer")