I have an ArcToolbox tool I created based on a script I wrote that needs an input parameter that equals the folder location of the ArcToolbox .tbx file from which the tool runs. I am distributing the toolbox, so users can run it from a variety of locations. How do I create a folder parameter that autofills with a default of the current .tbx location?
I have tried writing a bit of python under the Validation tab of the Tool properties:
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."""
stringFilter = self.params[1].filter
list = []
pathname = os.path.realpath(".")
list.append(pathname)
stringFilter.list = list
if not self.params[1].altered:
self.params[1].value = stringFilter.list[0]
return
But when I run the tool, the only text that autofills into the parameter reads, "RemoteDatabase"
arcpy.env.scratchFolder
. That always exists and can be used. Otherwise, see this answer for some known locations available via scripting: gis.stackexchange.com/questions/72348/…