3

I am trying to do some Tool Validation for a script I'm writing in ArcGIS 10.2. I have a Multivalue File field which the user can browse to a directory to select the files they require to run. When opening the browser I would like it to automatically browse to a specific folder where the files reside so it's quicker/easier for the use to select the files required. I've looked though the http://pro.arcgis.com/en/pro-app/arcpy/geoprocessing_and_python/programming-a-toolvalidator-class.htm documentation but can't see anything related to achiving this.

Any Thoughts on if this is possible?

enter image description here

1 Answer 1

1

Unfortunately, you won't be able to specify the default folder when browsing for the files.

I had a similar problem some years ago and was forced to work around this using two parameters. The first one - of Folder type; user can browse to (you can set its default value either in the script tool parameters Default property or in the ToolValidator class). The second one - of String type (multi value); user can select multiple files located within this folder.

This is how it looks in a tool. The logic for getting the files from a folder user has browsed to:

  def updateParameters(self):
    """Modify the values and properties of parameters before internal
    validation is performed.  This method is called whenever a parameter
    has been changed."""
    self.params[1].filter.list = [f for f in os.listdir(self.params[0].value.value) if
                                  os.path.isfile(os.path.join(self.params[0].value.value, f)
                                                 )]
    return

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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