Skip to content

Instantly share code, notes, and snippets.

@nohe427
Created March 30, 2015 15:51
Show Gist options
  • Save nohe427/7e0555f178cea68cf9d9 to your computer and use it in GitHub Desktop.
Save nohe427/7e0555f178cea68cf9d9 to your computer and use it in GitHub Desktop.
This is a sample filter for a long data type in Python.
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 = "ToolboxSample"
self.alias = "ToolboxSample"
# List of tool classes associated with this toolbox
self.tools = [Tool]
class Tool(object):
def __init__(self):
"""Define the tool (tool name is the name of the class)."""
self.label = "Tool"
self.description = ""
self.canRunInBackground = False
def getParameterInfo(self):
"""Define parameter definitions"""
# Input Features parameter
in_value = arcpy.Parameter(
displayName="Input Value",
name="in_value",
datatype="GPLong",
parameterType="Required",
direction="Input")
in_value.filter.type = "ValueList"
in_value.filter.list = [1,10,100]
params = [in_value]
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment