- Main Page
- Related Pages
- Modules
- Classes
- Examples

- Class List
- Class Hierarchy
- Class Members

Public Types | Static Public Member Functions

# MCommandMessage Class Reference

# OpenMaya - API module for common classes

Search for all occurrences

## Detailed Description

Helper class to handle MEL output.

This class is used to register for a callback for when certain MEL command related messages are generated.

The add callback method returns an id which is used to remove the callback.

To remove a callback use MMessage::removeCallback.

All callbacks that are registered by a plug-in must be removed by that plug-in when it is unloaded. Failure to do so will result in a fatal error.

Note:
  Setting up a callback using the addCommandCallback() method may degrade the performance of Maya since the installed callback will be invoked repeatedly as MEL operations are processed.

`#include <MCommandMessage.h>`

Inheritance diagram for MCommandMessage:
[legend]

List of all members.

## Public Types
enum | MessageType { kHistory, kDisplay, kInfo, kWarning, kError, kResult, kStackTrace }
| Types of output messages. More...
typedef void(* | MMessageFunction )(const MString &message, MCommandMessage::MessageType messageType, void *clientData)
| Pointer to a message function.
typedef void(* | MMessageFilterFunction )(const MString &message, MCommandMessage::MessageType messageType, bool &filterOutput, void *clientData)
| Pointer to a message filter function.
## Static Public Member Functions
static MCallbackId | addCommandCallback (MMessage::MStringFunction func, void *clientData=NULL, MStatus *ReturnStatus=NULL)
| This method registers a callback for command messages that are issued every time a MEL command is executed.
static MCallbackId | addCommandOutputCallback (MCommandMessage::MMessageFunction func, void *clientData=NULL, MStatus *ReturnStatus=NULL)
| This method registers a callback for whenever MEL commands generate output such as that which is printed into the command window.
static MCallbackId | addCommandOutputFilterCallback (MCommandMessage::MMessageFilterFunction func, void *clientData=NULL, MStatus *ReturnStatus=NULL)
| This method registers a callback for whenever MEL commands generate output such as that which is printed into the command window.
static const char * | className ()
| Returns the name of this class.
static MCallbackId | addProcCallback (MMessage::MStringIntBoolIntFunction func, void *clientData, MStatus *ReturnStatus)
| This method registers a callback that is executed every time a MEL procedure is run.

## Member Typedef Documentation

typedef void(* MMessageFunction)(const MString &message, MCommandMessage::MessageType messageType, void *clientData)

Search for all occurrences

Pointer to a message function.

Parameters:

  [in] | message | The command that was executed.
  [in] | messageType | The type of message.
  [in,out] | clientData | User defined data passed to the callback function.

typedef void(* MMessageFilterFunction)(const MString &message, MCommandMessage::MessageType messageType, bool &filterOutput, void *clientData)

Search for all occurrences

Pointer to a message filter function.

Parameters:

  [in] | message | The command that was executed.
  [in] | messageType | The type of message.
  [out] | filter | Bool that causes Maya to filter this message if set to true.
  [in,out] | clientData | User defined data passed to the callback function.

## Member Enumeration Documentation

enum MessageType

Search for all occurrences

Types of output messages.

Enumerator:

  kHistory | Command history. Search for all occurrences
  kDisplay | String to display unmodified. Search for all occurrences
  kInfo | General information. Search for all occurrences
  kWarning | Warning message. Search for all occurrences
  kError | Error message. Search for all occurrences
  kResult | Result from a command execution in the command window. Search for all occurrences
  kStackTrace | Stack trace. Search for all occurrences

## Member Function Documentation

MCallbackId addCommandCallback | ( | MMessage::MStringFunction | func,
|  | void * | clientData = `NULL`,
|  | MStatus * | ReturnStatus = `NULL`
| ) |  | `[static]`

Search for all occurrences

This method registers a callback for command messages that are issued every time a MEL command is executed.

It is only called when actual commands are executed and not when scripts are executed.

The callback function will be passed the any client data that was provided when the callback was registered.

NOTE: Setting up a callback using this method will degrade the performance of Maya since the installed callback will be invoked repeatedly as MEL operations are processed.

Parameters:

  [in] | func | The callback function.
  [in] | clientData | User defined data that will be passed to the callback function.
  [out] | ReturnStatus | Status code.

Returns:
  Identifier used for removing the callback.

Status Codes:
  - MS::kSuccess Operation succeeded
  - MS::kInsufficientMemory No memory available
  - MS::kFailure Error adding callback

MCallbackId addCommandOutputCallback | ( | MCommandMessage::MMessageFunction | func,
|  | void * | clientData = `NULL`,
|  | MStatus * | ReturnStatus = `NULL`
| ) |  | `[static]`

Search for all occurrences

This method registers a callback for whenever MEL commands generate output such as that which is printed into the command window.

The callback function will be passed the any client data that was provided when the callback was registered.

Parameters:

  [in] | func | The callback function.
  [in] | clientData | User defined data that will be passed to the callback function.
  [out] | ReturnStatus | Status code.

Returns:
  Identifier used for removing the callback.

Status Codes:
  - MS::kSuccess Operation succeeded
  - MS::kInsufficientMemory No memory available
  - MS::kFailure Error adding callback

MCallbackId addCommandOutputFilterCallback | ( | MCommandMessage::MMessageFilterFunction | func,
|  | void * | clientData = `NULL`,
|  | MStatus * | ReturnStatus = `NULL`
| ) |  | `[static]`

Search for all occurrences

This method registers a callback for whenever MEL commands generate output such as that which is printed into the command window.

This callback includes a boolean filter option which allows the callback to prevent the output of the message to the script editor and command line output. Setting the 'filterOutput' parameter to true, inside your callback will filter the output from the script editor and command line output.

The callback function will be passed the any client data that was provided when the callback was registered.

Parameters:

  [in] | func | The callback function.
  [in] | clientData | User defined data that will be passed to the callback function.
  [out] | ReturnStatus | Status code.

Returns:
  Identifier used for removing the callback.

Status Codes:
  - MS::kSuccess Operation succeeded
  - MS::kInsufficientMemory No memory available
  - MS::kFailure Error adding callback

const char * className | ( |  | ) | `[static]`

Search for all occurrences

Returns the name of this class.

Returns:
  The name of this class.

Reimplemented from MMessage.

MCallbackId addProcCallback | ( | MMessage::MStringIntBoolIntFunction | func,
|  | void * | clientData,
|  | MStatus * | ReturnStatus
| ) |  | `[static]`

Search for all occurrences

This method registers a callback that is executed every time a MEL procedure is run.

The callback will be executed once when the procedure is about to be executed, and again when it has exited. If a non-existent procedure is called the callback will be called once for entry but there will be no call on exit.

The callback function should have the following parameters:

func(const MString& procName, unsigned int procID, bool isProcEntry, unsigned int type, void* clientData)

Where: procName will be the name of the procedure being invoked procID is the ID for the procedure's invocation isProcEntry is true if the procedure is being entered, false otherwise type is an MCommandMessage::ProcType value, and denotes the type of call this is, a MEL Proc, or MEL Command clientData is a pointer to an unsigned integer which is the invocation ID of the procedure

The callback cannot be registered multiple times. To register a new callback function for this, please de-register the original callback first.

NOTE: Setting up a callback using this method can potentially degrade the performance of Maya since the installed callback will be invoked repeatedly as MEL procedures are executed.

Parameters:

  [in] | func | The callback function.
  [in] | clientData | User defined data that will be passed to the callback function.
  [out] | ReturnStatus | Status code.

Returns:
  Identifier used for removing the callback.

Status Codes:
  - MS::kSuccess Operation succeeded
  - MS::kInvalidParameter Callback already registered
  - MS::kFailure Error adding callback

MCommandMessage MCommandMessage MCommandMessage MCommandMessage MCommandMessage MCommandMessage MCommandMessage MCommandMessage MCommandMessage MCommandMessage
MCommandMessage MCommandMessage MCommandMessage MCommandMessage MCommandMessage MCommandMessage MCommandMessage MCommandMessage MCommandMessage MCommandMessage