The Hello World example presented previously uses DeclareSimpleCommand(). This example is more comprehensive and more illustrative of how command plug-ins are typically coded.
#include <stdio.h>
#include <maya mstring.h>
#include <maya marglist.h>
#include <maya mfnplugin.h>
#include <maya mpxcommand.h>
#include <maya miostream.h>
class helloWorld : public MPxCommand
{
public:
MStatus doIt( const MArgList& args );
static void* creator();
};
MStatus helloWorld::doIt( const MArgList& args ) {
cout << "Hello World " << args.asString( 0 ).asChar() << endl;
return MS::kSuccess;
}
void* helloWorld::creator() {
return new helloWorld;
}
MStatus initializePlugin( MObject obj ) {
MFnPlugin plugin( obj, "Autodesk", "1.0", "Any" );
plugin.registerCommand( "HelloWorld", helloWorld::creator );
return MS::kSuccess;
}
MStatus uninitializePlugin( MObject obj ) {
MFnPlugin plugin( obj );
plugin.deregisterCommand( "HelloWorld" );
return MS::kSuccess;
}