0

I am building a python tool in ArcGIS. When I build the parameters I will have 3:

  1. Choose a shapefile (parameter data type = shapefile)
  2. Choose an SQL query (parameter data type = SQL Expression)
  3. Choose an output folder for a .xls report (parameter data type = Folder)

The first 2 parameters are an either/or scenario. The user will either choose a shapefile for the input or they will build an SQL Query on a very specific feature class (I do not want them to choose both parameters).

Whichever option the user choose, the parameter will be eventually used as the 'clip feature' in the arcpy.Clip_analysis function.

  1. Is there a way to limit the user from choosing both (i.e. if they choose the shapefile option, have the SQL query grey out automatically and vice versa). Maybe using the validator class?
  2. I want to 'Obtain From' a very specific feature class to be used in the SQL parameter. The parameter property for 'Obtain From' only allows me to obtain from another parameter. Is there any way to 'Obtain From' it's own source? It won't allow me to enter a default datasource and choose that for the 'Obtain From'. Maybe I can also do this through the validator class as well?
1

Ignoring your first question since it seems beside the point and could be answered in a separate question, I don't think it is possible to "hardcode" a SQL expression parameter's source with a Python script tool, but you should be able to with ModelBuilder by just not exposing the "specific" feature class as a model parameter. I do not believe the Obtained From parameter property is exposed to the ToolValidator class, so you can't set it there either.

On the other hand, if can accept making a fourth parameter for the "hardcoded" feature class, perhaps you could set its default value and make it disabled, and set the SQL expression parameter's Obtained From property to it.

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.