[Maya Python Api] You are not licensed to use to use the ... command. Error?

I’m trying to create a simple command plugin with python, but i get this strange error when i try to run it.

Warning: Calling syntax creator function failed

Error: RuntimeError: file <string> line 2: You are not licensed to use the “myCmd” command.

A search of the internet turns up some really old threads and some cryptic hints about choosing flag names that don’t conflict with other commands, but that doesn’t help me since i’ve already given the flags some heavily customized names.

I’m building off the sample code in the devit folder, so i’m not sure where i went off the rails…

Here are some relevant threads I found online:




class MyCommand(mpx.MPxCommand):
    CMD_NAME = 'myCmd'
    ARG_TYPE = '-r_et'
    ARG_TYPE_LONG = '-r_type'
    ARG_ALL = '-r_a'
    ARG_ALL_LONG = '-r_all'
    ARG_SEL = '-r_s'
    ARG_SEL_LONG = '-r_selected'
    
    def __init__(self):
        mpx.MPxCommand.__init__(self)
        self.__type = ''
        self.__all = False
        self.__sel = False
    
    @staticmethod
    def syntaxCreator():
        syntax = om.MSyntax()
        syntax.addFlag(MyCommand.ARG_TYPE, MyCommand.ARG_TYPE_LONG, om.MSyntax.kString)
        syntax.addFlag(MyCommand.ARG_ALL, MyCommand.ARG_ALL_LONG, om.MSyntax.kBoolean)
        syntax.addFlag(MyCommand.ARG_SEL, MyCommand.ARG_SEL_LONG, om.MSyntax.kBoolean)
        return syntax
        
    @staticmethod
    def cmdCreator():
        return mpx.asMPxPtr(MyCommand())
    
    def doIt(self, argList):
        self.parseArgs(argList)
    
    def parseArgs(self, argList):
        argData = om.MArgDatabase(self.syntax(), argList)
        if argData.isFlagSet(MyCommand.ARG_TYPE):
            self.__type = argData.flagArgumentString(MyCommand.ARG_TYPE, 0)
        if argData.isFlagSet(MyCommand.ARG_ALL): 
            self.__all = argData.flagArgumentBool(MyCommand.ARG_ALL, 0)  
        if argData.isFlagSet(MyCommand.ARG_SEL):
            self.__sel = argData.flagArgumentBool(MyCommand.ARG_SEL, 0)

Ok, I think i found my problem. From the docs:

[in] shortName the string representing the short (< 4 character) version of the flag
[in] longName the string representing the int (> 3 character) version of the flag

thanks