У меня проблема с примером плагина команды от Maya 2013 API Код для плагина был разбит на .h и .cpp-файл для ясности, но в противном случае он должен быть прав.Maya plugin console-out not writing
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;
}
Он успешно компилируется на ОС Windows 7 x64 Visual Studio 12 с Maya 2013 библиотек 64. Когда он загружается в диспетчере плагинов, отмечается (он должен распечатать статус инициализации). Но когда он выгружен, появляется печать инициализации. Кто-нибудь знает, почему это так?
Вы можете разбить это вниз до минимального кода, необходимого воспроизвести проблему? –
Удалено файл cmake и некоторый код в плагине (redo/undo stuff) – Martinnj
@Martinnj пытается использовать 'std :: cout << std :: endl' или пытаться использовать' std :: cout.flush() ; поток может просто не сливаться. – PeterT