AnsweredAssumed Answered

Check for checkbox status

Question asked by TomGeo on Oct 11, 2014
Latest reply on Oct 12, 2014 by TomGeo

Writing a tool within a Python toolbox I ran into the problem of checking the status of some checkbox.

While setting a default value for the checkbox is no problem,

 

parameter_bool.value = True

 

it comes kind of strange to retrieve the status. If I am not completely wrong then every parameter has two possibilities to achieve that: value, and valueAsText.

 

First I tried to check against the value:

 

if parameters[0].value is True:

 

then against valueAsText,

 

if paramaters[0].valueAsText == 'true':

 

It took me a bit to realize that valueAsText will return either 'true' or 'None'. Why does it not return 'false'?

However to check against it did not work. This part of the loop was never touched...

I ended up in using:

 

if parameters[0].value:

or

if not parameter[0].value:

 

Can somebody explain to me why it is impossible to check against the textual value by using the same strings that will be returned if I retrieve them this way?:

 

arcpy.AddMessage(str(parameters[0].valueAsText))

 

Wouldn't it be much easier to simply check the value against True/False?

Outcomes