Hi all, I am wondering if it's possible to make a script tool parameter showing or hiding depending on other parameter's value by user's inputing through coding in Validation or some other trick?
It's part of the validation.
Parameter objects have a Boolean enabled property
A parameter's value property returns an object, unless the parameter isn't populated, in which case the value returns None. To safeguard against a parameter not being populated, use a if check prior to using its value.
The code snippet below tests whether the value is equal to the string "Get Spatial Weights From File". This test works because the parameter data type is a string.
# If the option to use a weights file is selected, enable the # parameter for specifying the file, otherwise disable it if self.params.value: # check that parameter has a value if self.params.value == "Get Spatial Weights From File": self.params.enabled = True else: self.params.enabled = False
Thank you Terhune. It almost solve my problem, but it will be better if parameters invisible instead unselectable, or is it possible to popup another script parameters panel waiting for user's interactive inputs as an alternative?
I don't know if this will work, but if you choose a parameter type of "Derived" it will not show, but the user also doesn't have an option to choose either. But maybe you can work with that to get what you need.