class MFnPlugin

Jump to documentation

: public MFnBase Register and deregister plug-in services with Maya

Inheritance:

MFnPlugin < MFnBase

public members:

MFnPlugin ()
MFnPlugin ( MObject & object, const char* vendor = "Unknown", const char* version = "Unknown", const char* requiredApiVersion = "Any", MStatus * ReturnStatus = 0L )
virtual ~MFnPlugin ()
virtual MFn::Type type () const
MString vendor ( MStatus * ReturnStatus=NULL ) const
MString version ( MStatus * ReturnStatus=NULL ) const
MString apiVersion ( MStatus * ReturnStatus=NULL ) const
MString name ( MStatus * ReturnStatus=NULL ) const
MString loadPath ( MStatus * ReturnStatus=NULL ) const
MStatus setName ( const MString & newName, bool allowRename = true )
MStatus setVersion ( const MString & newVersion )
MStatus registerCommand (const MString & commandName, MCreatorFunction creatorFunction, MCreateSyntaxFunction createSyntaxFunction = NULL)
MStatus deregisterCommand ( const MString & commandName )
MStatus registerControlCommand (const MString & commandName, MCreatorFunction creatorFunction )
MStatus deregisterControlCommand (const MString & commandName)
MStatus registerModelEditorCommand (const MString & commandName, MCreatorFunction creatorFunction, MCreatorFunction paneCreatorFunction)
MStatus deregisterModelEditorCommand (const MString & commandName)
MStatus registerContextCommand ( const MString & commandName, MCreatorFunction creatorFunction)
MStatus registerContextCommand ( const MString & commandName, MCreatorFunction creatorFunction, const MString & toolCmdName, MCreatorFunction toolCmdCreator, MCreateSyntaxFunction toolCmdSyntax = NULL )
MStatus deregisterContextCommand ( const MString & commandName )
MStatus deregisterContextCommand ( const MString & commandName, const MString & toolCmdName )
MStatus registerNode ( const MString & typeName, const MTypeId & typeId, MCreatorFunction creatorFunction, MInitializeFunction initFunction, MPxNode::Type type = MPxNode::kDependNode , const MString * classification = NULL)
MStatus deregisterNode ( const MTypeId & typeId )
MStatus registerShape ( const MString & typeName, const MTypeId & typeId, MCreatorFunction creatorFunction, MInitializeFunction initFunction, MCreatorFunction uiCreatorFunction, const MString * classification = NULL)
MStatus registerTransform ( const MString & typeName, const MTypeId & typeId, MCreatorFunction creatorFunction, MInitializeFunction initFunction, MCreatorFunction xformCreatorFunction, const MTypeId & xformId, const MString * classification = NULL)
MStatus registerData ( const MString & typeName, const MTypeId & typeId, MCreatorFunction creatorFunction, MPxData::Type type = MPxData::kData )
MStatus deregisterData ( const MTypeId & typeId )
MStatus registerDevice ( const MString & deviceName, MCreatorFunction creatorFunction )
MStatus deregisterDevice ( const MString & deviceName )
MStatus registerFileTranslator ( const MString & translatorName, char* pixmapName, MCreatorFunction creatorFunction, char* optionsScriptName = NULL, char* defaultOptionsString = NULL, bool requiresFullMel = false )
MStatus deregisterFileTranslator ( const MString & translatorName )
MStatus registerIkSolver ( const MString & ikSolverName, MCreatorFunction creatorFunction )
MStatus deregisterIkSolver ( const MString & ikSolverName )
MStatus registerUI (const MString & creationProc, const MString & deletionProc, const MString & creationBatchProc = "", const MString & deletionBatchProc = "")
MStatus registerDragAndDropBehavior ( const MString & behaviorName, MCreatorFunction creatorFunction)
MStatus deregisterDragAndDropBehavior ( const MString & behaviorName )
MStatus registerImageFile ( const MString & imageFormatName, MCreatorFunction creatorFunction, const MStringArray & imageFileExtensions)
MStatus deregisterImageFile ( const MString & imageFormatName)
static MObject findPlugin ( const MString & pluginName )
static bool isNodeRegistered ( const MString & typeName)
MTypeId matrixTypeIdFromXformId (const MTypeId & xformTypeId, MStatus * ReturnStatus=NULL)
MStringArray addMenuItem ( const MString & menuItemName, const MString & parentName, const MString & commandName, const MString & commandParams, bool needOptionBox = false, MString *optBoxFunction = NULL, MStatus *retStatus = NULL )
MStatus removeMenuItem ( MStringArray & menuItemNames)
MStatus registerMaterialInfo ( MString & type , MMaterialInfoFactoryFnPtr fnPtr )
MStatus unregisterMaterialInfo (const MString &typeName)
MStatus registerBakeEngine ( MString &typeName, MBakeEngineCreatorFnPtr fnPtr )
MStatus unregisterBakeEngine (const MString &typeName)

Inherited from MFnBase:

public members:

virtual MFn::Type type () const
bool hasObj ( MFn::Type ) const
bool hasObj ( const MObject & ) const
MObject object ( MStatus * ReturnStatus = NULL ) const
virtual MStatus setObject ( MObject & object )
virtual MStatus setObject ( const MObject & object )

Documentation

Register plug-in supplied, commands, dependency nodes, etc. with Maya
Description

This class is used in the initializePlugin and uninitializePlugin functions in a Maya plugin in order to register new services with Maya. The constructor for this class is passed the MObject provided by Maya as an argument to initializePlugin and uninitializePlugin. Subsequent calls are made to the various "register" methods from inside initializePlugin, and to the various "deregister" methods from inside uninitializePlugin.

A plug-in's uninitializePlugin function is not called automatically when Maya exits. Meaning any code which deallocates resources or a similar task will be called when the plug-in is explicitly unloaded but not when Maya exits. In order to work-around this problem and execute the code when Maya exits use the MSceneMessage class's addCallback method with a message of "kMayaExiting". This will register a callback function that will be executed when the "kMayaExiting" message occurs. Use this message and the addCallback method to deallocate any resources when exiting.

A side effect of including MFnPlugin.h is to embed an API version string into the .o file produced. If it is necessary to include MFnPlugin.h into more than one file that comprises a plugin, the preprocessor macro MNoVersionString should be defined in all but one of those files prior to the inclusion of MFnPlugin.h. If this is not done, the linker will produce warnings about multiple definitions of the variable MApiVersion as the .so file is being produced. These warning are harmless and can be ignored. Normally, this will not arise as only the file that contains the initializePlugin and uninitializePlugin routines should need to include MFnPlugin.h.

Modules are related to the topic of plug-ins and are described next.

Modules

Modules provide a way of informing Maya where a third party plug-in has been installed. This is the recommended way of allowing Maya to know that a plug-in is available and is important for 3rd party developers who deliver plug-ins outside of the Maya installation procedure.

The list of directories that Maya searches for modules can be accessed through the MAYA_MODULE_PATH environment variable. Please consult the online documentation for more details on this environment variable. To examine this variable value, run the following from the MEL script editor:

	getenv "MAYA_MODULE_PATH";

The MAYA_MODULE_PATH contains a list of directories and within each module directory there are subdirectories that look like:

	<PRODUCT>\<VERSION>

Within that directory are zero or more text files. Each file has a single line that looks like this:

	+ <NAME> <VERSION> <PATH>

The fields are defined as:

If we had a plug-in named doubleHelix, the single line for a Windows installation might be:

	+ doubleHelix 6.0 c:\program files\DoubleHelix\

On Irix or Linux, we might have:

	+ doubleHelix 6.0 /usr/local/DoubleHelix/

When Maya starts up it will search the paths defined by MAYA_MODULE_PATH. For any paths found it will do the following:

When the Plug-in Manager is opened it will display the plug-ins described by the module files since the appropriate paths have been modified. Following the subdirectory naming structure using "plug-ins", "scripts" and "icons" will allow Maya to find your files properly.

NOTE: a specific module path may not exist on disk. This will not cause an error. Maya will skip over this path and continue to process the others.

Functions

MFnPlugin:: MFnPlugin ()

Description

Default class constructor. The function set is not attached to an MObject.

MFnPlugin:: MFnPlugin ( MObject & object, const char* vendor , const char* version , const char* requiredApiVersion, MStatus * ReturnStatus )

Description

Class constructor that initializes the function set to the given MObject. The MObject should the be one passed as an argument to either the initializePlugin or uninitializePlugin entry points of a Maya plug-in.

Arguments

  • object the MObject to attach the function set to
  • vendor a string identifying the vendor of this plug-in
  • version a string identifying the version number of this plug-in
  • requiredApiVersion if the plug-in is known to work with only a specify API version, that version can be specified here. This argument is current not used by the Maya API.
  • ReturnStatus the return status
    • MS::kSuccess if the function set is successfully attached
    • MS::kInvalidParameter if the function set is not allowed to attach to this MObject or if the MObject does not represent a valid Maya object

MFnPlugin:: ~MFnPlugin ()

Description

The class destructor.

MFn::Type MFnPlugin:: type () const

Description

Return the type of this function set.

Return Value

  • the constant MFn::kPlugin

MString MFnPlugin:: vendor ( MStatus * ReturnStatus ) const

Description

Return the vendor string supplied in the MFnPlugin constructor.

Arguments

  • ReturnStatus the return status
    • MS::kSuccess if successful
    • MS::kObjectDoesNotExist if the function set is not attached to an MObject.

Return Value

  • an MString containing the vendor name

MString MFnPlugin:: version ( MStatus * ReturnStatus ) const

Description

Return the version string supplied in the MFnPlugin constructor.

Arguments

  • ReturnStatus the return status
    • MS::kSuccess if successful
    • MS::kObjectDoesNotExist if the function set is not attached to an MObject.

Return Value

  • an MString containing the version string

MString MFnPlugin:: apiVersion ( MStatus * ReturnStatus ) const

Description

Return the required API version string supplied in the MFnPlugin constructor.

Arguments

  • ReturnStatus the return status
    • MS::kSuccess if successful
    • MS::kObjectDoesNotExist if the function set is not attached to an MObject.

Return Value

  • an MString containing the required API version string

MString MFnPlugin:: name ( MStatus * ReturnStatus ) const

Description

Return the name by which Maya knows this plug-in.

Arguments

  • ReturnStatus the return status
    • MS::kSuccess if successful
    • MS::kObjectDoesNotExist if the function set is not attached to an MObject.

Return Value

  • an MString containing the plug-in name

MString MFnPlugin:: loadPath ( MStatus * ReturnStatus ) const

Description

Determine the path where the plugin was loaded.

Arguments

  • ReturnStatus the return status
    • MS::kSuccess if successful
    • MS::kObjectDoesNotExist if the function set is not attached to an MObject.

Return Value

  • an MString containing path name to the location of the plugin.

MStatus MFnPlugin:: setName ( const MString & newName, bool makeUnique )

Description

Set the name by which Maya knows this plug-in.

Arguments

  • newName the new name
  • makeUnique if true and the requested name is already in use, then Maya will create an unused name for this plug-in. If false, and the name is in use, do not change the current name.

Return Value

  • MS::kSuccess if successful
  • MS::kFailure makeUnique was false, and the requested name is already in use
  • MS::kObjectDoesNotExist if the function set is not attached to an MObject.

MStatus MFnPlugin:: setVersion ( const MString & newVersion )

Description

Set the version name for this plug-in.

Arguments

  • newVersion the new version

Return Value

  • MS::kSuccess if successful
  • MS::kObjectDoesNotExist if the function set is not attached to an MObject.

MStatus MFnPlugin:: registerCommand ( const MString & commandName, MCreatorFunction creatorFunction, MCreateSyntaxFunction createSyntaxFunction)

Description

Register a new command with Maya. Once registered, the command can be invoked from MEL in a manner identical to built-in Maya commands.

Arguments

  • commandName the name of the command to register
  • creatorFunction a pointer to a function that will return a pointer to a new instance of the class (derived from MPxCommand) that implements the new command.
  • createSyntaxFunction a pointer to a function that will return a new instance of a syntax object (MSyntax) that implements the syntax of the command.

Return Status

  • MS::kSuccess if the command is successfully registered
  • MS::kObjectDoesNotExist if the function set is not attached to an MObject

MStatus MFnPlugin:: deregisterCommand ( const MString & commandName )

Description

Deregister the user defined command from Maya. Once deregistered the command can no longer be invoked from MEL.

Arguments

  • commandName the name of the command to deregister

Return Value

  • MS::kSuccess if successful
  • MS::kFailure the command was not owned by this plug-in
  • MS::kObjectDoesNotExist if the function set is not attached to an MObject.

MStatus MFnPlugin:: registerControlCommand ( const MString & commandName, MCreatorFunction creatorFunction )

Description

Register a new control command with Maya. Once registered, the command can be invoked from MEL in a manner identical to built-in Maya commands.

Arguments

  • commandName the name of the control to register
  • creatorFunction a pointer to a function that will return a pointer to a new instance of the class(derived from MPxControlCommand) that implements the new command.

Return Status

  • MS::kSuccess if the command is successfully registered
  • MS::kObjectDoesNotExist if the function set is not attached to an MObject

MStatus MFnPlugin:: deregisterControlCommand ( const MString & commandName )

Description

Deregister the user defined control command from Maya. Once deregistered the command can no longer be invoked from MEL.

Arguments

  • commandName the name of the command to deregister

Return Value

  • MS::kSuccess if successful
  • MS::kFailure the command was not owned by this plug-in
  • MS::kObjectDoesNotExist if the function set is not attached to an MObject.

MStatus MFnPlugin:: registerModelEditorCommand (const MString & commandName, MCreatorFunction creatorFunction, MCreatorFunction viewCreatorFunction)

Description

Register a new model editor command with Maya. Once registered, the command can be invoked from MEL in a manner identical to built-in Maya commands.

Arguments

  • commandName the name of the command to register
  • creatorFunction a pointer to a function that will return a pointer to a new instance of the class (derived from MPxEditorCommand) that implements the new command.
  • viewCreatorFunction a pointer to a function that will return a pointer to a new instance of the class (derived from MPx3dModelView) that implemented the new view associated with this command.

Return Status

  • MS::kSuccess if the command is successfully registered
  • MS::kInvalidParameter if the function set is not attached to an MObject

MStatus MFnPlugin:: deregisterModelEditorCommand ( const MString & commandName )

Description

Deregister the user defined editor command from Maya. Once deregistered the command can no longer be invoked from MEL.

Arguments

  • commandName the name of the command to deregister

Return Value

  • MS::kSuccess if successful
  • MS::kFailure the command was not owned by this plug-in
  • MS::kObjectDoesNotExist if the function set is not attached to an MObject.

MStatus MFnPlugin:: registerContextCommand ( const MString & commandName, MCreatorFunction creatorFunction )

Description

Register a new context command with Maya. Once registered, the context can be used to create a new tool that can be used in a manner identical to built-in Maya tools.

Arguments

  • commandName the name of the context command to register
  • creatorFunction a pointer to a function that will return a pointer to a new instance of the class (derived from MPxToolCommand) that implements the new tool.

Return Status

  • MS::kSuccess if the command is successfully registered
  • MS::kObjectDoesNotExist if the function set is not attached to an MObject

MStatus MFnPlugin:: registerContextCommand (const MString & commandName, MCreatorFunction creatorFunction, const MString & toolCmdName, MCreatorFunction toolCmdCreator, MCreateSyntaxFunction toolCmdSyntax)

Description

Register a new context command and a new tool command with Maya. This version of registerContextCommand must be used if a tool command (a class derived from MPxToolCommand) is used within the context. The method newToolCommand of MPxContext will return a new instance of the tool command that can be used in the context.

Once registered, the context can be used to create a new tool that can be used in a manner identical to built-in Maya tools. The tool command can also be used as a MEL command.

Arguments

  • commandName the name of the context command to register
  • creatorFunction a pointer to a function that will return a pointer to a new instance of the class (derived from MPxToolCommand) that implements the new tool.
  • toolCmdName the name of the tool command to register
  • toolCmdCreator a pointer to a function that will return a pointer to a new instance of the class (derived from MPxToolCommand) that implements the new command.
  • toolCmdSyntax a pointer to a function that will return a new instance of a syntax object (MSyntax) that implements the syntax of the command.

Return Status

  • MS::kSuccess if the command is successfully registered
  • MS::kObjectDoesNotExist if the function set is not attached to an MObject

MStatus MFnPlugin:: deregisterContextCommand ( const MString & commandName )

Description

Deregister the given user defined context command from Maya. Once deregistered the user defined tool can no longer be used.

Arguments

  • commandName the name of the context command to deregister

Return Value

  • MS::kSuccess if successful
  • MS::kFailure the command was not owned by this plug-in
  • MS::kObjectDoesNotExist if the function set is not attached to an MObject.

MStatus MFnPlugin:: deregisterContextCommand ( const MString & commandName, const MString & toolCmdName )

Description

Deregister the given user defined context command and tool command from Maya. Once deregistered the user defined tool can no longer be used and the tool command can no longer be invoked from MEL.

Arguments

  • commandName the name of the context command to deregister
  • toolCmdName the name of the command to deregister

Return Value

  • MS::kSuccess if successful
  • MS::kFailure the command was not owned by this plug-in
  • MS::kObjectDoesNotExist if the function set is not attached to an MObject.

MStatus MFnPlugin:: registerNode ( const MString & typeName, const MTypeId & typeId, MCreatorFunction creatorFunction, MInitializeFunction initFunction, MPxNode::Type type , const MString * classification )
Description

Register a new dependency node with Maya. Once registered, the node can be used from MEL in a manner identical to built-in Maya nodes.

Arguments

  • typeName the name of the new type of node
  • typeId a unique id that identifies this node
  • creatorFunction a pointer to a function that will return a pointer to a new instance of the class (derived from MPxNode) that implements the new node type
  • initFunction a pointer to a function that will initialize all the attributes of the new node type
  • type the type of plugin node to be registered
  • classification a string that is used in dependency nodes that are also shaders to provide more detailed type information to the rendering system. See the documentation for the MEL commands getClassification and listNodeTypes for information on the strings that can be provided.

Return Value

  • MS::kSuccess if the node type was successfully registered
  • MS::kFailure the registration failed.
  • MS::kObjectDoesNotExist if the function set is not attached to an MObject.

MStatus MFnPlugin:: deregisterNode ( const MTypeId & typeId )

Description

Deregister the given user defined dependency node type Maya. Once deregistered new instances of the user defined dependency node can no longer be created. Additionally, any existing instances of the node type will be changed to the special type Unknown and will no longer evaluate in the dependency graph although they will be saved correctly if the scene is written.

Arguments

  • typeId the unique type id of the node type to deregister

Return Value

  • MS::kSuccess if successful
  • MS::kFailure the node type was not owned by this plug-in
  • MS::kObjectDoesNotExist if the function set is not attached to an MObject.

MStatus MFnPlugin:: registerShape ( const MString & typeName, const MTypeId & typeId, MCreatorFunction creatorFunction, MInitializeFunction initFunction, MCreatorFunction uiCreatorFunction, const MString * classification )
Description

Registers the given user defined shape node with Maya. Once registered, the shape can be used from MEL in a manner identical to built-in Maya nodes.

To deregister the shape node use the MFnPlugin::deregisterNode() method.

Arguments

  • typeName the name of the new type of user defined shape node
  • typeId a unique id that identifies this node
  • creatorFunction a pointer to a function that will return a pointer to a new instance of the class (derived from MPxSurfaceNode) that implements the new shape node type
  • initFunction a pointer to a function that will initialize all the attributes of the new shape node type
  • uiCreatorFunction a pointer to a function that will return a pointer to a new instance of the class (derived from MGxSurfaceShapeUI) that is used to implement the drawing and selection functions of the user defined shape.
  • classification a string that is used in dependency nodes that are also shaders to provide more detailed type information to the rendering system. See the documentation for the MEL commands getClassification and listNodeTypes for information on the strings that can be provided.

Return Value

  • MS::kSuccess if the node type was successfully registered
  • MS::kFailure the registration failed.
  • MS::kObjectDoesNotExist if the function set is not attached to an MObject.

MStatus MFnPlugin:: registerTransform ( const MString & typeName, const MTypeId & typeId, MCreatorFunction creatorFunction, MInitializeFunction initFunction, MCreatorFunction xformCreatorFunction, const MTypeId & xformId, const MString * classification )
Description

Registers the given user defined transform node with Maya. Once registered, the transform can be used from MEL in a manner identical to built-in Maya nodes.

To deregister the transform node use the MFnPlugin::deregisterNode() method.

Arguments

  • typeName the name of the new type of user defined transform node
  • typeId a unique id that identifies this node
  • creatorFunction a pointer to a function that will return a pointer to a new instance of the class (derived from MPxTransform) that implements the new transform node type
  • initFunction a pointer to a function that will initialize all the attributes of the new transform node type
  • xformCreatorFunction a pointer to a function that will return a pointer to a new instance of the class (derived from MPxTransformationMatrix) that is used to implement the matrix functions of the custom transform. For default behavior, use the MPxTransformationMatrix::creator method.
  • xformId a unique id that identifies this transformation matrix. If MPxTransformationMatrix::creator is used, then MPxTransformationMatrix::baseTransformationMatrixId should be used.
  • classification a string that is used in dependency nodes that are also shaders to provide more detailed type information to the rendering system. See the documentation for the MEL commands getClassification and listNodeTypes for information on the strings that can be provided.

Return Value

  • MS::kSuccess if the node type was successfully registered
  • MS::kFailure the registration failed.
  • MS::kObjectDoesNotExist if the function set is not attached to an MObject.

MStatus MFnPlugin:: registerData ( const MString & typeName, const MTypeId & typeId, MCreatorFunction creatorFunction, MPxData::Type type )

Description

Register a new data type with Maya. Once registered, the data type can be passed between dependency nodes in a manner identical to built-in Maya data types.

Arguments

  • typeName the name of the data type to register
  • typeId the unique type id of the data type to register
  • creatorFunction a pointer to a function that will return a pointer to a new instance of the class (derived from MPxData) that implements the new data type.
  • type the type of data being registered, see the Type enum in MPxData.h for all available types

Return Status

  • MS::kSuccess if the data type is successfully registered
  • MS::kObjectDoesNotExist if the function set is not attached to an MObject

MStatus MFnPlugin:: deregisterData ( const MTypeId & typeId )

Description

Deregister the given user defined data type from Maya.

It is important to note that this method will always fail if there are any instances of the user-defined data in the scene. If the plug-in were to be allowed to deregister its implementation of the data, it would become impossible to save the scene since the writeASCII and writeBinary methods would no longer be accessible.

Arguments

  • typeId the unique type id of the data type to deregister

Return Value

  • MS::kSuccess if successful
  • MS::kFailure the data type is being used by current instances of nodes in the dependency graph
  • MS::kObjectDoesNotExist if the function set is not attached to an MObject.

MStatus MFnPlugin:: registerDevice ( const MString & deviceName, MCreatorFunction creatorFunction )

Description

Register a new input device with Maya. Once registered, the new input device can be connected to Maya actions using the assignInputDevice command in MEL in a manner identical to built-in Maya devices. In Maya 1.0, only Midi input devices are supported and the creatorFunction must return a pointer to a MPxMidiInputDevice instance. This interface will be generalized in a future release.

Arguments

  • deviceName the name of the device to register
  • creatorFunction a pointer to a function that will return a pointer to a new instance of the class (derived from MPxMidiInputDevice) that implements the new device.

Return Status

  • MS::kSuccess if the device is successfully registered
  • MS::kObjectDoesNotExist if the function set is not attached to an MObject

MStatus MFnPlugin:: deregisterDevice ( const MString & deviceName )

Description

Deregister the given user defined input device from Maya.

Arguments

  • deviceName the name of the input device to deregister

Return Value

  • MS::kSuccess if successful
  • MS::kObjectDoesNotExist if the function set is not attached to an MObject.

MStatus MFnPlugin:: registerFileTranslator ( const MString & translatorName, char* pixmapName, MCreatorFunction creatorFunction, char* optionsScriptName, char* defaultOptionsString, bool requiresFullMel )
Description

Register a new file translator with Maya.

It requires a name string containing the "name" by which Maya will refer to this file type, and a pathname to an "icon" file which Maya will use in its file selection dialogs.

Arguments

  • translatorName the string by which Maya will refer to this file type
  • pixmapName the pathname of the icon used in file selection dialogs
  • creatorFunction a pointer to a function that will return a pointer to a new instance of the class (derived from MPxFileTranslator) that implements the new file type.
  • optionsScriptName the name of a MEL script that will be used to display the contents of the options dialog during file open and save.
  • defaultOptionsString the default value of the options string that will be passed to the options script.
  • requiresFullMel this should be set to true if the reader method in the derived class intends to issue MEL commands via the MGlobal::executeCommand method. Setting this to true will slow down the creation of new objects, but allows MEL commands other than those that are part of the Maya Ascii file format to function correctly. This parameter defaults to false.

Return Status

  • MS::kSuccess if the file translator is successfully registered
  • MS::kObjectDoesNotExist if the function set is not attached to an MObject

MStatus MFnPlugin:: deregisterFileTranslator ( const MString & translatorName )

Description

Deregister the specified file translator with Maya.

Arguments

  • translatorName the name of the translator to deregister

Return Status

  • MS::kSuccess if the file translator is successfully registered
  • MS::kObjectDoesNotExist if the function set is not attached to an MObject

MStatus MFnPlugin:: registerIkSolver ( const MString & ikSolverName, MCreatorFunction creatorFunction )
Description

Register a new ik-solver with Maya. NOTE: this method is obsolete. Instead, register the IK solver as a node as described in the example plug-in simpleSolverNode.cpp.

  • ikSolverName the name of the new IK solver
  • creatorFunction a pointer to a function that will return a pointer to a new instance of the class (derived from MPxIkSolver) that implements the new file type.

Return Status

  • MS::kSuccess if the ik-solver is successfully registered
  • MS::kObjectDoesNotExist if the function set is not attached to an MObject

MStatus MFnPlugin:: deregisterIkSolver ( const MString & ikSolverName )

Description

Deregister the specified ik-solver with Maya. NOTE: this method is obsolete. Instead, register the IK solver as a node as described in the example plug-in simpleSolverNode.cpp.

Arguments

  • ikSolverName the name of the ik solver to deregister

Return Status

  • MS::kSuccess if the ik-solver is successfully registered
  • MS::kObjectDoesNotExist if the function set is not attached to an MObject

MStatus MFnPlugin:: registerUI (const MString & creationProc, const MString & deletionProc, const MString & creationBatchProc, const MString & deletionBatchProc)

Description

Sets the names of the mel procedures to be evaled to create and destroy any UI associated with the plugin.

You can use MEL procedure names as arguments to this method as long as the procedure is located in a file named procedure.mel. This works because, as described in the MEL documentation, when MEL is given a undefined procedure, it searchs MAYA_SCRIPT_PATH looking for a file with the name procedure.mel. If it finds such a file it is sourced and if the procedure was defined by the file, it is then executed.

Example: The procedure lassoToolCreateUI will be run when the plugin is loaded, the procedure lassoToolDeleteUI when the plugin is unloaded. This works as long as the MEL procedure lassoToolCreateUI is defined in a file called lassoToolCreateUI.mel and the procedure lassoToolDeleteUI is defined in a file called lassoToolDeleteUI.mel.

	
MStatus initializePlugin( MObject obj )
{
    MStatus status;

    MFnPlugin plugin( obj, "Alias - Example", "1.0", "Any");
    status = plugin.registerContextCommand( "lassoToolContext",
                                            lassoContextCmd::creator );

    if (!status) {
        status.perror("registerContextCommand");
        return status;
    }

    // set the mel procs to be run when the plugin is loaded / unloaded
    status = plugin.registerUI("lassoToolCreateUI", "lassoToolDeleteUI");
    if (!status) {
        status.perror("registerUIScripts");
        return status;
    }

    return status;
}

	

Arguments

  • creationProc The name of the procedure to be run when the plug in is loaded
  • deletionProc The name of the procedure to be run when the plug in is unloaded
  • creationBatchProc The name of the procedure to be run when the plug in is loaded in batch mode. The procedure should not contain UI related code.
  • deletionBatchProc The name of the procedure to be run when the plug in is unloaded in batch mode. The procedure should not contain UI related code.

Return Value

  • MS::kSuccess if successful
  • MS::kObjectDoesNotExist if the function set is not attached to an MObject.

MStatus MFnPlugin:: registerDragAndDropBehavior ( const MString & behaviorName, MCreatorFunction creatorFunction )

Description

Register a new drag and drop behavior with Maya. Once registered, the new behavior can be used to finish connections between node drag and drops from the hyperGraph/hyperShade to other nodes or Maya UI. Arguments

  • behaviorName the name of the drag and drop behavior to register
  • creatorFunction a pointer to a function that will return a pointer to a new instance of the class (derived from MPxDragAndDropBehavior) that implements the new behavior.

Return Status

  • MS::kSuccess if the bevavior is successfully registered
  • MS::kObjectDoesNotExist if the function set is not attached to an MObject

MStatus MFnPlugin:: deregisterDragAndDropBehavior ( const MString & behaviorName )

Description

Deregister the given drag and drop behavior from Maya.

Arguments

  • behaviorName the name of the behavior to deregister

Return Value

  • MS::kSuccess if successful
  • MS::kObjectDoesNotExist if the function set is not attached to an MObject.

MStatus MFnPlugin:: registerImageFile ( const MString & imageFormatName, MCreatorFunction creatorFunction, const MStringArray & imageFileExtensions)
Description

Register a new image file translator with Maya.

Arguments

  • imageFormatName the name of the image format to register
  • creatorFunction a pointer to a function that will return a pointer to a new instance of the class (derived from MImageFile) that implements the new file type.
  • imageFileExtensions this list of file extensions this image file should be associated with.

Return Status

  • MS::kSuccess if the image file type is successfully registered
  • MS::kFailure otherwise

MStatus MFnPlugin:: deregisterImageFile ( const MString & imageFormatName)

Description

Deregister the specified image file translator with Maya.

Arguments

  • imageFormatName the name of the image format to deregister

Return Status

  • MS::kSuccess if the image file type is successfully deregistered
  • MS::kFailure otherwise

MStatus MFnPlugin:: registerMaterialInfo ( MString & materialInfoName, MMaterialInfoFactoryFnPtr fnPtr)

Description

Registers a new material information type with Maya.

Arguments

  • materialInfoGen the new material info generator name.
  • fnPtr pointer to function that return a new instance of material information node.

Return Status

  • MS::kSuccess if the material info node is successfully registered.
  • MS::kFailure otherwise

MStatus MFnPlugin:: unregisterMaterialInfo (const MString & materialInfoName)

Description

Deregister the specified material info type with Maya.

Arguments

  • materialInfoGen the material info generator name.

Return Status

  • MS::kSuccess if the material info node is successfully deregistered
  • MS::kFailure otherwise

MStatus MFnPlugin:: registerBakeEngine ( MString & bakeEngineGenName, MBakeEngineCreatorFnPtr fnPtr)

Description

Registers a new bake engine type with Maya.

Arguments

  • bakeEngineGenName the new bake engine generator name.
  • fnPtr pointer to function that return a new instance of bake engine generator node.

Return Status

  • MS::kSuccess if the bake engine generator node is successfully registered.
  • MS::kFailure otherwise

MStatus MFnPlugin:: unregisterBakeEngine (const MString & bakeEngineGenName)

Description

Deregister the bake engine type with Maya.

Arguments

  • bakeEngineGenName the bake engine generator name.

Return Status

  • MS::kSuccess if the bake engine generator node is successfully deregistered
  • MS::kFailure otherwise

MObject MFnPlugin:: findPlugin ( const MString & pluginName )

Description

Returns an MObject corresponding to the named plugin. If the plugin isn't loaded, the MObject will be kNullObj. This MObject may be used in the same way as the MObject passed to the plugin's initializePlugin() function. Do not hold onto this MObject, if you need it again later, call findPlugin() again.

Arguments

  • pluginName the name of the plugin you want a handle for.

Return Status

  • An MObject corresponding to the plugin if the plugin is loaded.
  • MObject::kNullObj if the plugin isn't loaded.

bool MFnPlugin:: isNodeRegistered (const MString & typeName)

Description

Queries if the given typeName has been registered by maya or plugins.

Arguments

  • typeName the type name of a depend graph node to query.

Return Value

  • true if registered
  • false if not registered

MTypeId MFnPlugin:: matrixTypeIdFromXformId (const MTypeId & xformTypeId, MStatus * ReturnStatus)

Description

The function returns the MTypeId of the matrix when the MTypeId of the corresponding xform is given.

Arguments

  • xformTypeId the typeId of the transform.
  • ReturnStatus Return status.

Return Value

  • MTypeId TypeId of the corresponding transformation matrix, if found.

MStringArray MFnPlugin:: addMenuItem ( const MString & menuItemName, const MString & parentName, const MString & commandName, const MString & commandParams, bool needOptionBox, MString *optBoxFunction, MStatus *retStatus )

Description

The function adds the menuItem to the specified parent, and associates a command with it. Additionally, an option box can be created and a MEL function/command can be added to it. The function returns the names of the new menuItem and the optionBox created.

Arguments

  • menuItemName This will be used as the label for the menuItem.
  • parentName Name of the parent to which the new menuItem needs to be attached.
  • commandName Command to be attached.
  • commandParams Parameters for the command.
  • needOptionBox Boolean indicating whether an option box is required. Default value is false.
  • optBoxFunctionMEL Function to be attached to the option box. If the needOptionBox is false, then this argument will have no effect.
  • retStatus Return status.

Return Value

  • MStringArray returns the names of the new menuItems created. In case the method fails, and MStringArray has items in it, removeMenuItem() should be called on it to remove the unused UI references.

MStatus MFnPlugin:: removeMenuItem ( MStringArray & menuItemNames)

Description

The function removes the menuItem and the corresponding option box, if exists, from the UI.

Arguments

  • menuItemNames Names of the menuItem which needs to be removed.

Return Value

  • MStatus returns the status of command execution.

This class has no child classes.


Autodesk® Maya® 8.0 © 1997-2006 Autodesk, Inc. All rights reserved. doc++ Copyright