MLibrary Class Reference

#include <MLibrary.h>

List of all members.


Detailed Description

Set up Maya to run in library mode. (OpenMaya).

Initialize and cleanup routines for Maya running in library mode.

When creating a "library mode" Maya application, this class must be used in the program's main routine to initialize Maya, and later to cleanUp allocated Maya state. A typical usage would be:

    main(int argc, char **argv)
    {
        MStatus status;
        status = MLibrary::initialize (argv[0], true);
        if ( !status ) {
            status.perror("MLibrary::initialize");
            return (1);
        }

        // Maya API code goes here

        MLibrary::cleanup();
        return (0);
    }

If the call to cleanup is omitted, you will get errors when the program exits as the static destructors in the Maya libraries are run.

Public Member Functions

 MLibrary ()
virtual ~MLibrary ()

Static Public Member Functions

static MStatus initialize (char *applicationName, bool viewLicense=false)
static MStatus initialize (bool wantScriptOutput, char *applicationName, bool viewLicense=false)
static void cleanup (int exitStatus=0)


Constructor & Destructor Documentation

MLibrary::MLibrary (  ) 

The default class constructor.

MLibrary::~MLibrary (  )  [virtual]

The class destructor.


Member Function Documentation

MStatus MLibrary::initialize ( char *  applicationName,
bool  getViewLicense = false 
) [static]

Initialize the Maya library. This method must be called before any Maya functions sets are used. It is acceptable to instantiate Maya fundamental types before calling this, but attempts to do anything else cause unpredictable results. When writing a Maya library mode application, a call to this method should be the first line of main.

Arguments

  • applicationName The name of this application. Typically argv[0] is passed in this parameter.
  • getViewLicense
  • true if a view license version of the library is required.
  • false (default) if an edit license version of the library is required.
Returns:
Examples:

MStatus MLibrary::initialize ( bool  wantScriptOutput,
char *  applicationName,
bool  getViewLicense = false 
) [static]

Initialize the Maya library. This method must be called before any Maya functions sets are used. It is acceptable to instantiate Maya fundamental types before calling this, but attempts to do anything else cause unpredictable results. When writing a Maya library mode application, a call to this method should be the first line of main.

Arguments

  • wantScriptOutput Set to true if you wish script output to be generated. For example if you are using the the MGlobal::displayInfo() method.
  • applicationName The name of this application. Typically argv[0] is passed in this parameter.
  • getViewLicense
  • true if a view license version of the library is required.
  • false (default) if an edit license version of the library is required.
Returns:

void MLibrary::cleanup ( int  exitStatus = 0  )  [static]

Undo the initialization performed by the initialize method, cleanup allocated Maya structures in an orderly fashion and terminate the application.

Note: calling this method will cause the standalone application to exit. As a result this method should be called in place of the usual exit call that would normally be made when the application is finished its work.

Note: when this method causes the application to exit, it does so in a way that prevents any static destructors from being executed.

If a parameter is provided, its value is used as the exit status for the application.

If the application is terminated with exit instead of this method, it will return errors when the application exits as static destructors in the Maya libraries are run.

NOTE: This method will not return control to your application when it completes.

Arguments

  • exitStatus The exit code the application will return.
Examples:


Autodesk® Maya® 2009 © 1997-2008 Autodesk, Inc. All rights reserved. Generated with doxygen 1.5.6