Difference between revisions of "Snippet:Check Command Enabled"

From The Foundry MODO SDK wiki
Jump to: navigation, search
 
Line 13: Line 13:
 
   return True
 
   return True
 
</syntaxhighlight>
 
</syntaxhighlight>
|lang=Python Examples,
+
|lang=Python Examples, API Examples,
 
}}
 
}}

Latest revision as of 10:15, 26 November 2015

Description:

Function tests whether a MODO command is enabled or not.

Code:

def is_enabled(cmd_string) :
   msg = lx.service.Message().Allocate()
   cmd = lx.service.Command().SpawnFromString(cmd_string)[2]
   try:
      cmd.Enable(msg)
   except RuntimeError, e:
      if e.message == 'bad result: CMD_DISABLED':
         return False
      raise
   return True