I have created a few different ArcGIS Python Toolboxes, but one thing I can't quite understand is when to apply "schema.clone = True" to a parameter. All of the examples I have seen show that I should be using it for derived parameters, as shown below, taken from Parameter Dependencies.
# First parameter
param0 = arcpy.Parameter(
displayName="Input Features",
name="in_features",
datatype="GPFeatureLayer",
parameterType="Required",
direction="Input")
# Third parameter
param2 = arcpy.Parameter(
displayName="Output Features",
name="out_features",
datatype="GPFeatureLayer",
parameterType="Derived",
direction="Output")
param2.parameterDependencies = [param0.name]
param2.schema.clone = True
However, when I try that on my code, it says the Tool is invalid when looking at it in Catalog. It gives me the following error when I click on the "Why..." button.
Traceback (most recent call last):
File "<string>", line 481, in getParameterInfo
AttributeError: 'NoneType' object has no attribute 'clone'
Here is what my code looks like. It works perfectly when I remove the schema clone line, which is confusing me. What exactly does that line do and when do I need it?
# Input Table
input_table = arcpy.Parameter(
displayName="Table or Feature Class",
name="input_table",
datatype=["GPFeatureLayer", "GPTableView"],
parameterType="Required",
direction="Input")
params.append(input_table)
# Derived Output Table
output_table = arcpy.Parameter(
displayName="Derived Output Table or Feature Class",
name="output_table",
datatype=["GPFeatureLayer", "GPTableView"],
parameterType="Derived",
direction="Output")
output_table.parameterDependencies = [input_table.name]
output_table.schema.clone = True
params.append(output_table)
I am currently running version 10.4
input_table
definition?