MGlobal is a class that provides
you with a few global controls of maya. Executing mel scripts;
sending the user messages; selecting objects and setting the current
frame can all be performed with MGlobal.
Executing a mel script
You can execute any mel commands
you want using MGlobal::executeCommand.
You can also use MGlobal::sourceFile
to execute an entire script
// execute the mel command to make a sphere MGlobal::executeCommand(
// execute the specified mel script MGlobal::sourceFile(
Displaying messages to the
also offers you ways of notifying the user of errors, warnings
and/or general information. These messages appear in the output
pane of the maya script editor.
// display some info in the script editor MGlobal::displayInfo(
"some info" );
some error in the script editor MGlobal::displayError(
"some error" );
// display some warning in the script editor MGlobal::displayWarning(
"some warning" );
Accessing currently selected
MGlobal provides you with a mechanism
for selecting objects, and querying currently selected items.
The code on the right prints all of the currently selected objects.