C++ Maya插件控制台出不写

C++ Maya插件控制台出不写,c++,visual-studio,plugins,maya,C++,Visual Studio,Plugins,Maya,我对Maya 2013中的示例命令插件有一个问题。为了清晰起见,该插件的代码已拆分为.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

我对Maya 2013中的示例命令插件有一个问题。为了清晰起见,该插件的代码已拆分为.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();
};
//包括所需的标题。
#包括
#包括
#包括
#包括
#包括
#包括
//类来表示我们的命令。
类命令示例:公共MPxCommand
{
公众:
commandExample();
虚拟命令示例();
MStatus doIt(const MArgList&);
MStatus redoIt();
MStatus undoIt();
bool是可撤消的()常量;
静态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;
}
//包括文件的标题。
#包括“pluginCmd.h”
//命令对象的构造函数。
commandExample::commandExample(){
无法尝试使用:

 cout << "Something out" << endl;
cout尝试使用:

 cout << "Something out" << endl;

cout我在使用Visual Studio 2015和Maya 2016 x64编写插件时遇到了同样的问题

建议的解决办法

cout << "Something out" << endl;

不太理想,但至少我们可以看到输出…

在使用Visual Studio 2015和Maya 2016 x64编写插件时,我遇到了同样的问题

建议的解决办法

cout << "Something out" << endl;

不太理想,但至少我们可以看到输出…

您能将其分解为重现问题所需的最低代码吗?删除了cmake文件和插件中的一些代码(重做/撤消内容)@Martinj尝试使用
std::cout工作得很好,谢谢PeterT!你能把它分解成重现问题所需的最少代码吗?删除了cmake文件和插件中的一些代码(重做/撤消的东西)Martinnj尝试使用<代码> STD::CUT工作得很好,谢谢PeterT!从C++中,这是唯一可靠的解决方法。现在它是否有任何已知的副作用FE写入错误日志文件?它可能与.exe所用的启动目录有关。因为在从Windows搜索启动玛雅时,它有时仍然是H。广告常规“cout”这是我的工作,直到最近才停止工作。直到Windows 10—64位-玛雅2018都不工作。没有显示任何东西。只有MGOL::DISPLAYING和脚本编辑器上的类似工作。C++是目前唯一可靠的解决方案。它是否有任何已知的副作用F.E.写入到n错误日志文件?它可能与用于.exe的启动目录有关-因为从windows search启动Maya时,它有时仍然有常规的“cout”使用所有相同的二进制文件。到目前为止,这是我的解决方法,直到最近它停止工作。这在Windows 10-64位-Maya 2018上不起作用。未显示任何内容。只有MGlobal::displayInfo和脚本编辑器上的类似工作。