cannot write to the output window


#1

Hi,

no idea what I have done wrong, but I can no longer write to the output window of Maya2016 with vs2015. Maya itself can and also mel:trace can, but not me : (

So, any idea?

thanks


#2

How do you try to write to output window?


#3

Haggi : )
I tried ‘std::cout’ and ‘printf’, both fail…


#4

Yupp, I run into the same problem some time ago. I had no problems on my dev machine, but it failed completely on other machines. Then I tried:

MStreamUtils::stdOutStream()

And everything worked fine :slight_smile:


#5

Haggi,
great, that worked!

But, since than, do you always have to create that ostream?
And still, ‘printf’ does not work…


#6

Here is an example how I use it:
https://github.com/haggi/appleseed-maya/blob/master/src/utilities/logging.cpp#L57


#7

Ah, I have had just a brief look into that ostream stuff, but obviously std::endl is not included. So, I did it like this:

#include <string>
#include <iostream>

#ifdef __DEFINE_SCI_COUT__
#include <maya/MStreamUtils.h>
#define __CREATE_SCI_COUT__ ostream & sciCout = MStreamUtils::stdOutStream();
#else
#define __CREATE_SCI_COUT__ extern ostream & sciCout;
#endif
#define sciEndl "
"; sciCout.flush();
__CREATE_SCI_COUT__;

Then I can simply convert ‘cout << “bla” << endl;’ into 'sciCout << “bla” << sciEndl;

edit: wow, thats cool! Its not possible to directly cout anything but MString and chars. If I try to print a int, Maya crashes. Thats bad, its the same with MGlobal::displayInfo. I have to create a MString with the data I want to cout first…Holy sh…


#8

I just started printing to cerr when that happened to me.


#9

Yep, I’ve always had to use cerr instead of cout on Windows to print to Maya’s Output Window.


#10

Ah, so this seems to be a common experience…
I will change to cerr, thanks!


#11

ooooops, std::cerr is not working, too : ]


#12

Try to launch maya from Command Prompt if you r using windows.
I think C++ std::cout sends output data to the stream
So in this case. The command prompt acts as the stream receiver
CMIIW

C:\Program Files\Autodesk\Maya2017\bin>maya.exe

Try it again. Good Luck