2

I have a folder and it contains two feature classes, e.g., a.shp and b.shp. The script tool created has two parameters. The first one is the model location, and the second one needs a feature class (a.shp), as shown in the below picture. enter image description here What I really want is every time when I set up the model location for the first input, the second input will automatically find the a.shp as the input rather than the user needs to choose a.shp from that folder. I noticed that the dependency is probably what I really need, but there is no code example. Any suggestions?

I am using ArcGIS 10.3.1 Advanced License.

1 Answer 1

3

You want to look into Script Tool Validation - see Understanding validation in script tools and Customizing script tool behavior with Validation

Validation allows you to pass some arcpy code when your tool dialog is open, and have those results update/enable/disable/etc. the parameters in your tool dialog before you hit OK to run the tool.

As part of this you can do an if/else where it can check the value in field one, then populate the value in field two based on field one. If you wanted, you could also have dynamic drop-downs where the entire drop-down for field 2 changes based on your value in field one.

0

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.