I am trying to build a Python Toolbox, like in the following code snippet. However I got error because of the last line (Filter) . I have to filter the files because without the filter the output window shows all kind of data including Feature class.
# First parameter
param1 = arcpy.Parameter(
displayName="Output Raster Dataset",
name="in_rasterdataset",
datatype=["Raster Dataset"],
parameterType="Required",
direction="Output ")
param1 .filter.list = ["Raster"]
Solved! Go to Solution.
I reformatted your code. It does look like you have a syntax error, but maybe it is just a copy error.
If you want a python toolbox template, I suggest you try New > Python Toolbox or use the one in the help.
The Python toolbox template—Help | ArcGIS Desktop
Defining parameters in a Python toolbox—Help | ArcGIS Desktop
Defining parameter data types in a Python toolbox—Help | ArcGIS Desktop
The help has the keywords you want, for example, for datatype you probably want "GPRasterLayer" or "DERasterDataset", not "Raster". If there's only one, you should only specify the string, not a list.
If you get the datatype keyword correct, I don't think you need to define param.filter.list.
Perhaps you need to use "Raster Dataset" instead of "Raster"?
Best Regards,
Jim
I have already tried "Raster", "RASTER", "Raster Dataset" etc.
It does not work.
Thanks
Well, your link goes to your training record from which nothing can be accessed.
Perhaps if you share the actual error message it might help and confirm that the space in line 8 after param1 and .filter is just a copying issue.
I reformatted your code. It does look like you have a syntax error, but maybe it is just a copy error.
If you want a python toolbox template, I suggest you try New > Python Toolbox or use the one in the help.
The Python toolbox template—Help | ArcGIS Desktop
Defining parameters in a Python toolbox—Help | ArcGIS Desktop
Defining parameter data types in a Python toolbox—Help | ArcGIS Desktop
The help has the keywords you want, for example, for datatype you probably want "GPRasterLayer" or "DERasterDataset", not "Raster". If there's only one, you should only specify the string, not a list.
If you get the datatype keyword correct, I don't think you need to define param.filter.list.