I have been creating a toolbox that contains 4 parameters. Two of my parameters involve editing the labels of a shapefile. I want to have these two parameters as optional: if the user does not want to have the labels edited, then don't edit them!
I should mention that I'm not up to that point yet though. The two parameters are the label text size and a boolean to see if the user wants the text to be bold. I have set the parameters to be optional in my getParameterInfo method:
def getParameterInfo(self): """Define parameter definitions""" # First parameter = layer with customized features param0 = arcpy.Parameter( displayName = "Source layer with customized features", name = "source", datatype = "Feature Layer", parameterType = "Required", direction = "Input") # Second parameter = layers to which customized features will be applied param1 = arcpy.Parameter( displayName = "Layers with features to be updated", name = "updlayers", datatype = "GPValueTable", parameterType = "Required", direction = "Input") param2 = arcpy.Parameter( displayName = "Label Font Size", name = "labelFontSize", datatype = "GPDouble", parameterType = "Optional", direction = "Input") param3 = arcpy.Parameter( displayName = "Bold Font:", name = "labelBoldFont", datatype = "GPBoolean", parameterType = "Optional", direction = "Input") param1.columns = [['Feature Layer', 'Features']] params = [param0, param1, param2, param3] return params
However, although they are set as optional (param2 and param3), the tool still requires an input in both cases. Here is a screenshot of what I see when I open my toolbox. Notice the green bubble next to the last two parameters, which indicates that they are required:
Is there a way for the last two parameters to be truly optional? As in, the user does not have to do anything with them if they don't want to? I'd imagine that this is something I can do in the getParameterInfo() method, but I am unsure of how to do this. Would I be able to set default values for these parameters in some way?
One extra thing to mention is that if I click on the check box for bold font to enable it, and then click it again to disable it, the tool will run. This is a temporary workaround. However, it is not ideal. I would hope to have the user not have to interact with these options if they don't want to.