1

I have created a Python Tool in ArcGIS where most of the paramaters musts be ONLY Polygon Shapefiles. You can also look on my previous question:
Filter the Feature Layer parameter in Python Script Tool
Also, the user must be able to select ONLY Polygon Shapefiles either from the current MXD or his/her system.

In order to solve it, I tried to give the type "Feature Layer" on each parameter and filter them to show only polygons. But, I didn't manage to put the extra filter for Shapefiles. In this case it is the only think I miss.

FeatureLayerfilteredPolygons

The second attempt was the implementation of the answer on my previous question:

Filter the Feature Layer parameter in Python Script Tool

In this case, I had to enrich the suggested code with:

    lyr.supports("DATASOURCE")  

because I have groups in my data frames. I got the list of Polygon Shapefiles that are already open in the current MXD but I don't have the option to select a shapefile from the user system because (as suggested) the parameter type is String (the folder icon on the right side of the field is missing!).

FilteredStringField

To conclude:

  • Is there a way to filter the dropdown list of Feature Layer parameter inside ToolValidator, so that it shows ONLY Shapefiles (Polygons are already filtered)?
  • If the above is NO, then is there a way to add the folder icon next to the String parameter so that the user can select an external Polygon Shapefile?
  • If none of the above two answers are YES, then is there any other solution?

Your Answer

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

Browse other questions tagged or ask your own question.