Is there a way to write to the Command Response (1 line console window) . I'm not after coloured (warning) text - but that would be nice. Just a the Melonic equivalient to :
# writes to Maya Command Response import sys cheese = "Gwen Stefani" sys.stdout.write(cheese)
Cheers.
Solved! Go to Solution.
Solved by rflannery. Go to Solution.
To write a plain message, use "print":
$s="Hello There"; print ($s + "\n");
To write a colored warning message, use "warning":
$t="Oh, no!"; warning $t;
There is also a colored error message. Note that your script will stop executing if it encounters the "error" command:
$u = "Something went really wrong!"; error $u;
print "I will never reach this line of code\n";
Note that with "print", you generally want to include a newline, "\n", at the end of your message. With "warning" and "error" you don't have to include the newline.
Doh! And there was I looking for a clever solution....
I find it odd (and inconsistant) that print in MEL will write to the Command Response, but Python won't. 😐
Heh, I never noticed that before. I knew that you could use "cmds.warning" and "cmds.error" in Python, and those show output in the desired location. But sure enough, Python's "print" statement only shows the output in the Script Editor. (And there is no "cmds.print".)
Can't find what you're looking for? Ask the community or share your knowledge.