I am writing a tool to generate a MXD and some metadata. It works but I am wondering if there is a better way than I am using to write the Tool Validator class than I am? Wondering how I would add another value list (not derived)? My value list now is to pick a mxd from a list of mxds in a template folder. I would like to add a value list to make a liks of layer files to add from a folder of template layer files. I would not mind changing below code so getting the list of mxds from a folder is a seperate function, but when I do that I get errors.
import arcpy
import os
class ToolValidator(object):
"""Class for validating a tool's parameter values and controlling
the behavior of the tool's dialog."""
def __init__(self):
"""Setup arcpy and the list of tool parameters."""
self.params = arcpy.GetParameterInfo()
def initializeParameters(self):
"""Refine the properties of a tool's parameters. This method is
called when the tool is opened."""
return
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."""
folderPath=r"folderPathHere"#Folder of Map Templates
mapTemplates = []
for filename in os.listdir(folderPath):
fullpath = os.path.join(folderPath, filename)
if os.path.isfile(fullpath):
basename, extension = os.path.splitext(fullpath)
if extension.lower() == ".mxd":
mapTemplates.append(fullpath)
self.params[0].filter.list = mapTemplates
return
def updateMessages(self):
"""Modify the messages created by internal validation for each tool
parameter. This method is called after internal validation."""
return