The following is a new version of the hello command which uses MFnPlugin to register itself instead of using the macros in MSimple.h.
#include <stdio.h>
#include <maya mstring.h>
#include <maya marglist.h>
#include <maya mfnplugin.h>
#include <maya mpxcommand.h>
#include <maya miostream.h>
class hello : public MPxCommand
{
public:
MStatus doIt( const MArgList& args );
static void* creator();
};
MStatus hello::doIt( const MArgList& args ) {
cout << "Hello " << args.asString( 0 ).asChar() << endl;
return MS::kSuccess;
}
void* hello::creator() {
return new hello;
}
MStatus initializePlugin( MObject obj ) {
MFnPlugin plugin( obj, "Autodesk", "1.0", "Any" );
plugin.registerCommand( "hello", hello::creator );
return MS::kSuccess;
}
MStatus uninitializePlugin( MObject obj ) {
MFnPlugin plugin( obj );
plugin.deregisterCommand( "hello" );
return MS::kSuccess;
}
initializePlugin() and uninitializePlugin() must be present in all plug-ins. If both or either is absent the plug-in will not be loaded and the creator is necessary to allow Maya to create instances of the class. See the following for details.