Prevent Python script tool from automatically filling output boxes

883
2
01-09-2014 08:50 AM
AustinMilt
New Contributor III
I am creating a script tool as part of a Python Toolbox (.pyt) that performs some fairly basic tasks. The tool takes a single input file and creates three output rasters (see image). The problem I am having is that somewhere in Hidden ArcMap World, ArcMap is automatically populating the three output raster paths with the same path when the user gives the single input.

I have attempted to work around this in 2(+) ways.

  • by having a check in updateMessages that raises an error if any of the ouputs match path/name

  • by trying to automatically generate file names in updateParameters whenever the user has altered the input parameter (and the others dont yet have a "value" or have not been "altered")

How can I either [1] prevent ArcMap from populating parameter names without changing their status to "Optional" or [2] force ArcMap (or arcpy) to use different names when automatically populating those parameters?

[ATTACH=CONFIG]30378[/ATTACH]
Tags (2)
0 Kudos
2 Replies
PatrickJurgens
New Contributor III
Please post the top portion of your code where you parse out the input parameters.
0 Kudos
AustinMilt
New Contributor III
Please post the top portion of your code where you parse out the input parameters.


Sorry, which part are you talking about? The execute() method?

# ~~ execute() ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ #
    def execute(self, P, messages):
        """
        EXECUTE() calls ImpactScoreRasters.ImpactScoreRasters in Bungee's
        executing directory.
        """
        pK = self.paramOrder
        import arcpy
        
        # process parameters
        analysis = arcpy.Describe(P[pK['analysis']].value).catalogPath
        outPad = arcpy.Describe(P[pK['outPad']].value).catalogPath
        outRoad = arcpy.Describe(P[pK['outRoad']].value).catalogPath
        outPipe = arcpy.Describe(P[pK['outPipe']].value).catalogPath
        usePadFootprint = P[pK['usePadFootprint']].value



Or are you referring to the getParameterInfo portion?
    # ~~ __getParameterInfo__() ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ #
    def getParameterInfo(self):
        """Define parameter definitions"""
        
        import arcpy
        
        # input analysis object (pickled file)
        analysis = arcpy.Parameter(
            displayName = 'Analysis Object File',
            name = 'analysis',
            datatype = 'File',
            parameterType = 'Required',
            direction = 'Input'
        )
            
        # Output Pad Raster
        outPad = arcpy.Parameter(
            displayName = 'Output Pad Raster',
            name = 'outPad',
            datatype= 'Raster Dataset',
            parameterType = 'Required',
            direction = 'Output'
        )
        
        # Output Road Raster
        outRoad = arcpy.Parameter(
            displayName = 'Output Road Raster',
            name = 'outRoad',
            datatype= 'Raster Dataset',
            parameterType = 'Required',
            direction = 'Output'
        )
        
        # Output Pipe Raster
        outPipe = arcpy.Parameter(
            displayName = 'Output Pipeline Raster',
            name = 'outPipe',
            datatype= 'Raster Dataset',
            parameterType = 'Required',
            direction = 'Output'
        )
        
        # Use Pad Footprint Flag
        usePadFootprint = arcpy.Parameter(
            displayName = 'Use Pad Footprint?',
            name = 'usePadFootprint',
            datatype = 'Boolean',
            parameterType = 'Optional',
            direction = 'Input'
        )
        
        usePadFootprint.value = False

        # finish
        parameters = [
            analysis,
            outPad,
            outRoad,
            outPipe,
            usePadFootprint
        ]

        return parameters
0 Kudos