Check Command Enabled

From The Foundry MODO SDK wiki
Jump to: navigation, search

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