Command plug-in basic classes and functions
There are certain basic elements that command plug-ins share.
Basic classes
All command plug-ins need to use the following classes.
Class | Purpose |
---|---|
MFnPlugin |
Maya plug-in function set. This is always required when creating a plug-in |
MPxCommand |
The base command plug-in proxy class. All command plug-ins must extend this class. |
MSyntax |
Used to specify the flags and arguments passed to commands. |
MArgDatabase |
Used to parse the MArgList for the flags, arguments, and objects passed to the command. |
Basic functions and methods
All command plug-ins need to implement creator()
, doIt()
, initializePlugin()
, and uninitializePlugin()
. These functions and methods are all called by Maya at different times.
Function or method | Description |
---|---|
creator() |
Instantiates the command. creator() is a global function that must be implemented in your code. |
doIt() |
Executes the command's actions. It is invoked only once, the first time the command is run. doItI() is a member of MPxCommand and needs to be overridden in your code. See The doIt() and redoIt() methods for details. |
redoIt() |
Executes the command's actions. With the exception of the first time the command is run, it is called every time the command is run. redoItI() is a member of MPxCommand and needs to be overridden in your code. See The doIt() and redoIt() methods for details. |
undoIt() |
Undoes the command operations. undoItI() is a member of MPxCommand and needs to be overridden in your code. See Undoable commands for details. |
isUndoable() |
Indicates whether the command is undoable and that its actions should be added to Maya's undo queue. isUndoable() is a member of MPxCommand . It returns false by default and needs to be overridden in your code to return true if your command is undoable. See Undoable commands for details. |
addMenuItem() |
Attaches a command to a Maya menu item. addMenuItem() is a member of MFnPlugin and is called in initializePlugin() . |
removeMenuItem() |
Removes the command's menu item from the Maya menu. removeMenuItem() is a member of MFnPlugin and is called in uninitializePlugin() . |
initializePlugin() |
Called when a plug-in is loaded into Maya. Registers the plug-in. initializePlugin() is a global function that you must implement in your code. See Plug-in entry points for details. |
uninitializePlugin() |
Called when a plug-in is unloaded from Maya. Deregisters the plug-in. uninitializePlugin() is a global function that you must implement in your code.See Plug-in entry points for details. |