Select to view content in your preferred language

How to autogenerate a workspace and base name for output parameter in Python script tool?

3645
0
08-06-2014 04:01 AM
MarAlcaraz
Deactivated User

As all geoprocessing tools do, I would like my Python script tool to generate automatically the workspace and base name for outputs.

In ArcGIS Help online, "Understanding validation in script tools" says about internal validation that:

  • Generate a default catalog path for output datasets.

After reading carefully (maybe not enough) the "Customizing tool behavior in a Python toolbox" from ArcGIS Help, I have not been able to adapt my script .

I have modified the Validation Class adding the getParameterInfo method, with the following code:

def getParameterInfo(self):

    # Input raster

    param0 = arcpy.Parameter(displayName="Introduce Piezometry raster dataset:",

                                                  name="piezoras",

                                                  datatype="GPRasterLayer",

                                                  parameterType="Required", 

                                                  direction="Input")

    # Output raster

    param1 = arcpy.Parameter(displayName="Define output Groundwater Flow Direction raster dataset:",

                                                   name="direcras",

                                                  datatype="DERasterDataset",

                                                  parameterType="Required",

                                                  direction="Output")

    param1.parameterDependencies = [param0.name]

    param1.schema.clone = True

    params = [param0, param1]

    return params

Some doubts:

  1. The definitions for these parameters in Parameters Tab do not change, why? The code in Validation Tab is not related to Parameters Tab???
  2. How can I related them? With the displayName property? Where is the name property in Parameters Tab?
  3. In general, How to autogenerate a workspace and base name for output parameter in Python script tool in dialog tool window?

Thanks in advance

0 Kudos
0 Replies