Python Toolbox: Setting the tool Output Name and Location

250
1
03-04-2020 09:42 AM
AhmadSALEH1
Occasional Contributor III

Hi,

I am wondering why setting up the parameter type as in output makes the tool auto -populate the output location and name without me letting me set it or control the output name.

I have this script that does nothing yet, but I found out that when I try to set the input of the census layer, the output is gets populated automatically with random feature class name. How can I control  at least the feature class name 

 

    def getParameterInfo(self):
        """Define parameter definitions"""
        census=arcpy.Parameter(
            name="census",
            displayName="Census Tracts",
            direction="Input",
            datatype="Feature Layer",
            parameterType="Required")

     
        output_fc=arcpy.Parameter(
            name="output_fc",
            displayName="Output",
            direction="Output",
            datatype="GPFeatureLayer",
            parameterType="Required")


        params=[census,output_fc]

        return params
‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍

    def execute(self, parameters, messages):
        """The source code of the tool."""
        census=parameters[0].value


        output_fc=parameters[1].value

Thank you,

1 Reply
DanPatterson_Retired
MVP Esteemed Contributor

It is trying to be helpful.  You can change it.  Just like any builtin geoprocessing tool