Select to view content in your preferred language

Toolbox Tool parameter visible but not enabled

899
3
Jump to solution
07-17-2023 01:45 PM
samuel_e
Occasional Contributor

I am adapting a custom Python toolbox from ArcMap to ArcGIS Pro which assigns land use codes to parcels. This specific tool is for a special "Uncodable" label, so there is no user input besides clicking run.

In ArcMap, the code parameter appears filled in with the default value, but not editable:

samuel_e_0-1689626301467.png

I would like to know if there is a way to do the same in Pro: can I have the parameter be visible, but disabled so it can't be changed?

I want this so coders can do a visual check that Yes, this is the right code that I want to apply. If it's not possible to do that, is there a way to just put descriptive text in the Parameters pane saying "You are going to code it such and such"? Or can I add a message that no action is required? Since there is a parameter, but disabled, I can't even get the "no parameters" message.

Thank you!

0 Kudos
1 Solution

Accepted Solutions
DanPatterson
MVP Esteemed Contributor

would a derived parameter work?

Setting script tool parameters—ArcGIS Pro | Documentation

you can use SetParameterAsText or SetParameter there


... sort of retired...

View solution in original post

0 Kudos
3 Replies
DanPatterson
MVP Esteemed Contributor

would a derived parameter work?

Setting script tool parameters—ArcGIS Pro | Documentation

you can use SetParameterAsText or SetParameter there


... sort of retired...
0 Kudos
JohannesLindner
MVP Frequent Contributor

As Dan said, you could set it to Derived, that will show the "No parameters" message.

Alternatively, you can just reset the parameter's value in the updateParameters() method:

class Tool(object):
    def __init__(self):
        self.label = "Tool"
        self.description = ""
        self.canRunInBackground = False

    def getParameterInfo(self):
        return [
            arcpy.Parameter(name="code", displayName="Land Use Code", datatype="GPString", parameterType="Required", direction="Input")
            ]

    def updateParameters(self, parameters):
        parameters[0].value = "9999 - Not Classifiable"

    def updateMessages(self, parameters):
        parameters[0].setWarningMessage("This parameter is for information only, you can't edit it.")

    def execute(self, parameters, messages):
        return

Have a great day!
Johannes
0 Kudos
DanPatterson
MVP Esteemed Contributor

With a custom python toolbox, you can set the above within the tool dialog


... sort of retired...
0 Kudos