我對Maya 2013中的示例命令插件有問題API插件的代碼已被拆分爲.h和.cpp文件以保持清晰,但應該是正確的。瑪雅插件控制檯輸出不寫
pluginCmd.h:
// Include the needed headers.
#include <stdio.h>
#include <maya/MString.h>
#include <maya/MArgList.h>
#include <maya/MFnPlugin.h>
#include <maya/MPxCommand.h>
#include <maya/MIOStream.h>
// Class to represent our command.
class commandExample : public MPxCommand
{
public:
commandExample();
virtual ~commandExample();
MStatus doIt(const MArgList&);
MStatus redoIt();
MStatus undoIt();
bool isUndoable() const;
static void* creator();
};
pluginCmd.cpp:
// Include the header for the file.
#include "pluginCmd.h"
// Constructor for the command object.
commandExample::commandExample() {
cout << "In commandExample::commandExample()\n";
}
// Destructor for the command object.
commandExample::~commandExample() {
cout << "In commandExample::~commandExample()\n";
}
// The actual command/work to be performed.
MStatus commandExample::doIt(const MArgList&) {
cout << "In commandExample::doIt()\n";
return MS::kSuccess;
}
// The creator is called when the command is invoked and sets up the command object.
void* commandExample::creator() {
cout << "In commandExample::creator()\n";
return new commandExample();
}
// Gets called when the plugin is loaded into Maya.
MStatus initializePlugin(MObject obj) {
// Set plugin registration info: Author, plugin-version and Maya version needed.
MFnPlugin plugin(obj, "Martin Jørgensen", "1.0", "Any");
plugin.registerCommand("commandExample", commandExample::creator);
// Print to show plugin command was registered.
cout << "In initializePlugin()\n";
return MS::kSuccess;
}
// Gets called when the plugin is unloaded from Maya.
MStatus uninitializePlugin(MObject obj)
{
MFnPlugin plugin(obj);
plugin.deregisterCommand("commandExample");
// Print to show the plugin was unloaded.
cout << "In uninitializePlugin()\n";
return MS::kSuccess;
}
它與Maya 2013 x64的庫編譯成功的Windows 7 64位系統的Visual Studio 12。 當它被加載到插件管理器中時,記錄會發生(它應該打印初始化狀態)。但是當它被卸載時,初始化打印出現。有沒有人有一個線索,爲什麼這是?
你能打破這種下降到所需的最小碼重現問題? –
刪除cmake文件和插件中的一些代碼(redo/undo stuff) – Martinnj
@Martinnj嘗試使用'std :: cout << std :: endl'或嘗試使用'std :: cout.flush() ;流可能不會沖洗。 – PeterT