Hello, I have different methods within the same script tool how I can apply filter so that the user will select different method and run code
for one of your parameters, define it as a text parameter and make a value list with your options.
For each option, create a def that performs the task
import blah
method = arcpy.GetParameterAsText(0) # a value list of the method names
params = arcpy.GetParameterAsText(1)
def method1(params):
"""method1 functionality"""
Do stuff
return something
def method2(params):
"""method2 functionality"""
Do stuff
return something
if method == "first":
result = method1(params)
else:
result = method2(params)
print("Here is the amazing result : {}".format(result))
Dan Patterson Thanks for your reply, what I want to do to call one function rescale (input, mode, other parameters)
inside mode there is different method {edge, warp,}, if the user select one of the method it will be different result ?
Dan Patterson What I meant only I want to change one parameter and run the tool?
Mina Alsaad, I read your question and your responses, and I am having a hard time figuring out your question. I realize there may be a language barrier occurring, but that makes it even more important to provide specifics and examples rather than speaking in general.
Thanks for your reply, Sure I am trying to use ready function that need arguments such (raster, scale , and method)
what I need the user to select the method from drop down menu and run the tool ?
If I understand you correctly, you have a function with 3 parameters:
To use this function inside a script tool, you have to define 3 parameters for the tool:
In the method parameter, define a filter list with valid method names. This way, you have a dropdown list with predefined things like "warp", "edge", etc.
Then you change your script:
# imports # get the script parameters raster_param = arcpy.GetParameterAsText(0) scale_param = arcpy.GetParameterAsText(1) # convert to int or float as needed method_param = arcpy.GetParameterAsText(2) # this parameter has a filter list, # so you know it can only be "warp" or "edge". # define your function (I think you already have that) def your_function(raster, scale, method): # stuff if method == "warp": # warp implementation if method == "edge": # edge implementation # more stuff # call your function your_function(raster_param, scale_param, method_param)