@mfersaoui You misunderstand the return value.
This is not a single true/false flag, but a set of flags. As I mentioned,
CMD_ENABLED stands for the enabling of the command (greyed out if not set), and
CMD_VALUE stands for the checked state (in case of icons, the background changes, as you saw in your test). These two flags are not mutually exclusive but can be used together! (use
or to join).
The actual value to use if you want neither flag set is simply
False works in this case because the numeric equivalent of false is 0.
from c4d import gui
op = doc.GetActiveObject()
if op is not None:
if op.GetType() == c4d.Ocube :
return c4d.CMD_ENABLED | c4d.CMD_VALUE
elif op.GetType() == c4d.Ocylinder :
# Main function
# Execute main()
If you watch the above script as icon in a toolbar, you will see all four state combinations depending on what primitive you select. If nothing is selected, the icon is grayed out. If you select a cylinder, the icon is still grayed out and unselectable but the background changes to make clear it's checked. A cube will show both the checked and active states, and some other object will show only the active state.
To be fair, the standard default script in R20 mentions False explicitly though.