class Tool(object): def __init__(self): """Define the tool (tool name is the name of the class).""" self.label = "label" self.description = "" self.canRunInBackground = False def getParameterInfo(self): """Define parameter definitions""" p0 = arcpy.Parameter( displayName="Basis-DLM (Ebene Jahr auswählen)", name="pfad", datatype="DEFolder", parameterType="Required", direction="Input") p1 = arcpy.Parameter( displayName="Bundesland der Gemeinde", name="bula", datatype="GPString", parameterType="Required", direction="Input") p1.value = "hh" p2 = arcpy.Parameter( displayName="zugehörige VG25 (Geodatabase) wählen", name="vg25", datatype="DEWorkspace", parameterType="Derived", direction="Output") # Set the filter to accept only local (personal or file) geodatabases p2.filter.list = ["Local Database"] p2.value = r"M:\eingangsdaten\geodaten\endfassung\gebiete\VG25\2010\vg_25.gdb" p3 = arcpy.Parameter( displayName="Output Feature Class", name="out_fc", datatype="DEShapefile", parameterType="Required", direction="Output") p3.value = "D:\workspace\sie02_f_2010.shp" p4 = arcpy.Parameter( displayName="AGS der Gemeinde (Vorschlag = Hamburg)", name="ags", datatype="GPString", parameterType="Required", direction="Input") p4.value = "02000000" p5 = arcpy.Parameter( displayName="Workspace (optional)", name="ziel", datatype="DEWorkspace", parameterType="Optional", direction="Input") # Set the filter to accept only local (personal or file) geodatabases p5.filter.list = ["Local Database"] p5.value = "#" params = [p0, p1, p2, p3, p4, p5] return params
thanks, dan for your answer. you're clearly right. but that didn't cause the error.
In the meantime, i found the fault: if you want to use keywords for parameter data types, you need the arcgis 10.1 service pack 1.
After installing sp1, everything workes fine 🙂
See @ arcgis online help:http://resources.arcgis.com/en/help/main/10.1/index.html#/Defining_parameter_data_types_in_a_Python_...
How should I define the data type in python script, if I don't have the possibility to upgrade to SP1?
I can not find anything that works, always showing this error: "ValueError: ParameterObject: Invalid input value for DataType property"
Hi Aida,
Presuming this is on an English-version of ArcGIS, you should be able to use any of the values from the first column in the big parameter table from this page:
http://resources.arcgis.com/en/help/main/10.2/index.html#//001500000035000000
-Dave
In addition to David's answer, I've also made a small module which converts between the names that I've found useful when I need to make a toolbox that works in 10.1 and 10.1SP1+:
EsriOceans/datatype-names · GitHub
It's relatively easy to use, you just set the parameter 'datatype' attribute to the desired type, e.g.:
from datatype import datatype dt = datatype.DataType() ... parameter.datatype = dt.format('Raster Dataset')
Note that this is only really useful if you're trying to make a toolbox that works across all versions consistently, if you're just running it locally, then David's technique is completely the way to go.