I'm writing an arcpy script for a tool that has a large number of parameters (around 10).

About half of these are "dependent" (perhaps not in the technical sense of the term), as in [first parameter] "1. Add a new layer or use existing" (binary 1 for new layer or 0 for old layer possible response) [next parameter] "2. {if 1 in first parameter} Specify workspace for new layer

It is in this way that I am describing the parameters as dependent.

My question is whether it is possible to have parameter 2 appear only if parameter 1 has a response that warrants it? I.e. if the user uses the layer in the existing .mxd then there is no need to specify the workspace.

I've looked through the various parameter options, but there doesn't seem to be a way to do this. Any advice would be greatly appreciated

2 Answers 2


You can't hide parameters, but you can enable/disable them through script tool validation. E.g.:

if self.params[0].value:
    self.params[1].enabled = True
    self.params[1].enabled = False

Will enable parameter 1 if and only if parameter 0 has a value. This would go in the ToolValidator's updateParameters function.


You cannot base the dialogue boxes on any of the inputs to those boxes, on the fly. This would require the dialogue box to run a 'check' and read a function of yours while you are still inputting values.

I see a couple ways of doing what you want:

Make the second (and subsequent) parameters optional, and then in your code: if param1 == 'x': param2 = arcpy.GetParameterAsText(1) else: pass #more controls to base your flow on only having 1 param, as 2nd didnt fit.

The other way would be a bit more complex, but more flexible. You could only ask for 1 parameter right away, and then if param1 == 'x': param2 = raw_input("Ask user for Param 2.")

Then evaluate that string as your second parameter, as you would using GetParameterAsText.

I've never seen this done in an arcmap context (getting input on the fly) so you'd probably have to run it from F5 (run) and not through a tool...

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.