import arcgisscripting gp = arcgisscripting.create() gp.SetParameterAsText(2,gp.GetParameterAsText(1))
class ToolValidator: """Class for validating a tool's parameter values and controlling the behavior of the tool's dialog.""" def __init__(self): """Setup the Geoprocessor and the list of tool parameters.""" import arcgisscripting as ARC self.GP = ARC.create(9.3) self.params = self.GP.getparameterinfo() def initializeParameters(self): """Refine the properties of a tool's parameters. This method is called when the tool is opened.""" self.params[1].Enabled = False self.params[1].Filter.List = [] return def updateParameters(self): """Modify the values and properties of parameters before internal validation is performed. This method is called whenever a parmater has been changed.""" if self.params[0].Altered: self.params[1].Enabled = True self.params[1].Filter.List = str(self.params[0].Value).replace("'",'').split(';') if self.params[1].Altered: self.params[2].Value = str(self.params[1].Value) return def updateMessages(self): """Modify the messages created by internal validation for each tool parameter. This method is called after internal validation.""" return
No -- not possible
I am OK with this approach as long as I can control which output variables are visible in ModelBuilder. For instance, if the user supplies 3 rasters for the tool, 3 green ovals will show up as the tool's output (instead of 3 green ovals and 37 white ovals). This way the user gets a less messy model. Is this possible?
Unfortunately, the number of variables a tool outputs is fixed -- they are part of the tool signature. There is no tool (or tool you can create) that dynamically creates some unknown number of outputs. Iteration with lists/series is probably your best bet. The only other thing I can think of is a hack -- create a script tool that outputs a known number of rasters -- a sufficiently large number of variables to handle whatever multivalue input you give it, then populate each output raster. In Python, it would be something like this:in_multivalue = gp.getparameterastext(0)rasters = in_multivalue.split(";")i = 1for raster in rasters: gp.setparameterastext(i, raster) i = i + 1
in_multivalue = gp.getparameterastext(0) rasters = in_multivalue.split(";") i = 1 for raster in rasters: gp.setparameterastext(i, raster) i = i + 1
If you are working with 9.3 or 9.3.1 try using the variable of type list or series. List of inputs will all run together and create a list of individual outputs. The individual outputs will have to use %i% in the output name as in-line variable substitution. Download this example and read help:http://resources.esri.com/geoprocessing/index.cfm?fa=codeGalleryDetails&scriptID=15728Read how to use lists, series and inline variable substitution:http://webhelp.esri.com/arcgisdesktop/9.3/index.cfm?TopicName=Iteration_using_Listshttp://webhelp.esri.com/arcgisdesktop/9.3/index.cfm?TopicName=Iteration_using_Serieshttp://webhelp.esri.com/arcgisdesktop/9.3/index.cfm?TopicName=In-line_variable_substitutionHope it helps.
Angemeldete Mitglieder können Beiträge verfassen, Updates folgen und mehr. Neu hier? Registriere ein kostenloses Konto.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.