Maya API : format messages to the script editor

,

Can someone help me use the Maya API to format messages to the script editor?

			MString msg;
			std::cout << "Mesh: " << mesh.id << "\n"; //prints to stdout / Maya ourpur window
			msg.format("Mesh: ", mesh.id.c_str()); // based on API examples.
			MGlobal::displayInfo(msg); // prints "//  //" in script editor

I can get stdout to the output window, I just want the info to be in the script editor
I want to format stuff like printf( "data result = %s", data)

You need format specifiers, don’t got maya in front of me at the moment but it would be something like this.

MString msg;
msg.format("Mesh: ^1s", mesh.id.c_str());
MGlobal::displayInfo(msg);

you might need to wrap the mesh.id part into a MString as well, i forget if it will do a implicit cast or not

1 Like

ah so it’s MEL format command. eewww.
MString.format will accept a c_string

yep its gross, and from the time where everyone just implemented there own string type for every framework