I would like to create a new shapefile based on input.
My input is DATE parameter. This is my code for input parameter:
param = arcpy.Parameter(
displayName="TARIKH",
name="date_feature",
datatype="Date",
parameterType="Required",
direction="Input")
and then the value in this parameter will be analysed using this code:
out_path = "C:/Last"
geometry_type = "POLYGON"
out_name = #DATEINPUT
result = arcpy.CreateFeatureclass_management(out_path, out_name,geometry_type)
The main point is, I don't know how to input all this code into toolbox code.
#This is the full code which I don't know where to put and what to insert into an .pyt toolbox
import arcpy
arcpy.env.overwriteOutput = True
class Toolbox(object):
def __init__(self):
"""Define the toolbox (the name of the toolbox is the name of the
.pyt file)."""
self.label = "Toolbox"
self.alias = ""
# 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"""
param = arcpy.Parameter(
displayName="TARIKH",
name="date_feature",
datatype="Date",
parameterType="Required",
direction="Input")
#date_features.filter.list = ["Point","Polyline","Polygon"]
#params = [date_features]
return
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."""
self.param[0] = date_feature
print "Your new shapefile sucessfull created"
out_path = "C:/Last"
geometry_type = "POLYGON"
out_name = date_features
result = arcpy.CreateFeatureclass_management(out_path, out_name,geometry_type)
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