I have some Python script tools in ArcGIS for Desktop.
I need to reproduce what all geoprocessing tools do when the first input parameter is introduced: autogenerate a workspace and basename for the outputs.
How can I do that?
I have some Python script tools in ArcGIS for Desktop. I need to reproduce what all geoprocessing tools do when the first input parameter is introduced: autogenerate a workspace and basename for the outputs. How can I do that? |
|||||||||||||||||||||
closed as unclear what you're asking by PolyGeo♦, Get Spatial, Matthias Kuhn, neogeomat, Erica Aug 27 '14 at 11:19Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question. |
|||||||||||||||||||||
|
You should use arcpy.Describe() and/or the os.path Python module. For example:
You can also check for the existence of the output if you want to make sure it doesn't already exist, increment the suffix if it does, etc. EDIT: Based on the example above, if you want to have this
And your script should look like this:
Don't forget to import all necessary modules in both codes. Refer to Customizing script tool behavior, this is where the code comes from and there are other examples for other use cases. |
|||||||||||||||||||||
|
Not sure what you mean. The only options are to "derive" a parameter, ie. when you select a featureclass as a first parameter, one of the derived parameters could be a list of fields for the second input parameter. Alternately, you can provide defaults for any parameter so that when a tool is opened, it will appear as the default option. |
|||||
|
The simplest solution I have found thanks to GISGe's hint is modifying only the updateParameter() method in validationtool class, adding this code.
This will generate a string with the default workspace with basename, "output". I dont have to modify the python script at all. Thanks to all!!! |
|||
|