I have several scripts that I have working from inside PythonWin. I am now experimenting with running these from inside ArcMap 10.0 so I can have a user define the parameters of the script. An important part of designing this popup for the user is choosing a "data type" for each parameter. However, I find ESRI's information about data types for parameters of little use for figuring out which to choose to get different results for user interaction.

For instance, say I have a script uses the dissolve tool in some way and I would like to have the user choose what type of "statistics_fields" they want in the final resulting shp file that the script returns (there are nine choises: FIRST, LAST...etc). Specifically, I would like to know how to choose the correct data type for this parameter so that the final user interface:

a) Provides a list of all nine choices available and allows the user to pick up to 9 variables that they would like to be included in the attribute table of the resulting shp file.

b) Provides a list of all nine choices as a pull down menu and allows the user to only pick one that ends up in the attribute table of the resulting shp file.*

How can I accomplish a) and b)? Perhaps I need to do more than just choosing the right data type?


Unfortunately you're right - the documentation on data types that ESRI provides isn't great to say the least. A couple of notes which might help you get started...

  • If you look at the documentation for other tools you can see the datatype that ESRI has used - for example, the Dissolve tool uses a Feature Layer for in_features, and a Value Table for statistics_fields - unfortunately we don't have access to all of these (including value table)
  • Some objects can be filtered with a customisable Value List, including String. The restricts the input to only those options
  • If a datatype is multivalue it will pass a semicolon ';' separated text string for that argument

So, to answer your question, the easiest way to achieve a and b would be to create a String datatype, change the Filter to a Value List (and type in the options) and make sure that Multivalue is yes. That way the user can select one or more items from the list and it will pass to your script.

You then just need to split the argument by the semicolon, and filter if they've passed in any duplicates (which this unfortunately doesn't prevent).

Good luck!

  • Thanks - that helps a lot! As far as us not having access to all the datatypes: is this just something ESRI hasn't gotten to in writing the Python library? (I assume that using ArcObjects, this access issue does not exist?) – GIStack Dec 1 '11 at 22:09
  • No worries! I suspect so as it comes down to them exposing the datatype through the toolbox interface, and for the most part a lot of the ones that are missing are unique to one tool. And because all toolbox does is pass string arguments to the Python script as it's being run, in almost all cases you can put them together from the other parameters. As you say though, I'm pretty sure that the problem doesn't exist in ArcObjects. – om_henners Dec 1 '11 at 22:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.