PDA

View Full Version : Plugin problems


ajk48n
06-02-2003, 07:48 AM
I can get the Hello World plugin to compile and I seem to be able to make a .mll file fine, however when I try to load it in Maya, I get the error

Error: initializePlugin function could not be found in plug-in (helloWorld)

Anyone have any ideas?

brooklyn
06-02-2003, 08:36 AM
You are compiling it for the right version of Maya?

Also are you trying to load it using the command line (it might not be in the correct path - env variables), or using the Plug-in Manager?

Hugh
06-02-2003, 08:51 AM
Is this the helloWorldCmd.cpp file from the plugins dir?

Just taken a look at it - it's using DeclareSimpleCommand() to initialise it....

Not entirely sure how this works, but try using the following stuff for setting it all up properly:

#include <maya/MSimple.h>
#include <maya/MGlobal.h>

class helloWorldCmd : public MPxCommand
{
public:
helloWorldCmd(); // The Constructor - run when this class is created
virtual ~helloWorldCmd(); // The Destructor - run when it's restroyed
MStatus doIt( const MArgList& );
MStatus redoIt();
MStatus undoIt();
bool isUndoable() const;
static void* creator();
}

// The actual creator - the code in here will be run when the class is created
helloWorldCmd::helloWorldCmd()
{
}

// The destructor - again, will be run when the class is destroyed.
helloWorldCmd::~helloWorldCmd()
{
}

// This function is called to create the class in the first place
void* helloWorldCmd::creator()
{
return new helloWorldCmd();
}

// This code will be run when the command is called. In this, I've
// printed "Hello World" both to the output (Output Window in
// Windows, and terminal in Linux)
MStatus helloWorldCmd::doIt( const MArgList& argList )
{
printf("Hello World\n"); // Print "Hello World" to the output window or command line
MGlobal::displayInfo("Hello World"); // Print "Hello World" to the script history window

return MS::kSuccess;
}

// This function would be used if the command was defined as
// undoable (see below) - it would be called when a redo was
// requested - this command would often be called at the end
// of doIt()
MStatus helloWorldCmd::redoIt()
{
return MS::kSuccess;
}

// This function would be used if the command was defined as
// undoable (see below) - it does exactly what it says on the tin -
// undoes the command...
MStatus helloWorldCmd::undoIt()
{
return MS::kSuccess;
}

// If we want this command to be undoable, we return 'true', otherwise, return 'false'
bool helloWorldCmd::isUndoable() const
{
return false;
}

// This is a global function (notice the lack of a 'helloWorldCmd::'
// before the function name) - this is the function that is first called
// when the plugin loads - this tells the plugin what functions can
// be used, and what the name for the command is...
MStatus initialisePlugin( MObject obj )
{
MStatus status;
MFnPlugin plugin( obj, "Your name or company name", "plugin version");

status = plugin.registerCommand( "helloWorld", helloWorldCmd::creator );
if(!status)
{
status.perror("registerCommand - helloWorld");
return status;
}
return status;
}

Sorry if that looks slightly long and complicated - the functions to worry about are the doIt and initialise functions - the rest are just the ones that are needed by the system, that don't really do anything

Anyway, I hope that's at least slightly helpful.... If, for any reason, it doesn't work (it should, but I just typed it straight in - didn't actually try to run it), do say and I'll try and write something more comprehensible.

brooklyn
06-02-2003, 09:00 AM
Ok I tried to get the same error.

And I did by omitting the line #include <maya/MGlobal.h>
after #include <maya/MSimple.h>

ajk48n
06-02-2003, 03:22 PM
Thanks for the help. I'll try them when I get home. The Hello World I was trying was the one from the developer's toolkit help.

#include <maya/MSimple.h>
DeclareSimpleCommand( helloWorld, "Alias|Wavefront", "5.0");
MStatus helloWorld::doIt( const MArgList& )
{
printf("Hello World\n");
return MS::kSuccess;
}

Hopefully adding MGlobal is all it needs.

Thanks again for all the help.

CGTalk Moderation
01-15-2006, 08:00 AM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.