How to handle parameterType?

3861
3
12-19-2014 05:13 AM
ThomasBecker1
Occasional Contributor II

Hi,

I do have a little problem in my business logic of my Python tool.

screenshot.png

In case the user does not have street and municipality names for the addresses the fields 'Municipality names' and 'Street name' should not only be disabled but also not Required. However, when the appropriate checkbox is set to False these Fields are required.

Is there any possibility to disable a parameter in a Python toolbox that the parameterType is neglected?

Also, that I have to give a parameterType to a checkbox (or GPBoolean), or that there is a 'Required' given as default value is a bit weird.

Looking forward to any suggestion on how to solve these issues.

Bests Thomas

0 Kudos
3 Replies
AlexanderNohe1
Regular Contributor II

Hi Thomas,

A couple of months ago I had the same problem and after some research found that the "Required" parameter property is read-only as documented here:

Customizing tool behavior in a Python toolbox

http://resources.arcgis.com/en/help/main/10.1/index.html#/Customizing_tool_behavior_in_a_Python_tool...

As a workaround, what I did was if a box was checked or textbox was filled in, I would use the addIDMessage and add error 735.

AddIDMessage (arcpy)

http://resources.arcgis.com/en/help/main/10.1/index.html#//018v00000022000000

000735 : <value>: Value is required.

ArcGIS Help 10.1

What this did was that when the value was enabled, I could make the text box required and when the user went to run it, it would through an error asking for that value to be filled in.

Does this help?

0 Kudos
ThomasBecker1
Occasional Contributor II

Hi Alexander,

it sounds like a solution, although I do not fully get through it.

Would you have some code example to illustrate it?

How do you deal with the parameterType of the textboxes initially and how do you influence them by using the AddIDMessage?

Bests Thomas

0 Kudos
AlexanderNohe1
Regular Contributor II

Hello Thomas,

I don't have a code sample just yet but what would happen is that when your add the id message, that id message would only appear if the textbox is enabled.  If the textbox is disabled, the id message would not display.

Thanks,

Alexander N.

0 Kudos