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

PolyGeo
65.5k29 gold badges115 silver badges349 bronze badges
asked Jan 5, 2018 at 12:17

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

answered Jan 5, 2018 at 13:05

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.