Community
Maya Programming
Welcome to Autodesk’s Maya Forums. Share your knowledge, ask questions, and explore popular Maya SDK topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Write to command response in MEL

3 REPLIES 3
SOLVED
Reply
Message 1 of 4
Anonymous
1769 Views, 3 Replies

Write to command response in MEL

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.

 

 

3 REPLIES 3
Message 2 of 4
rflannery
in reply to: Anonymous

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.

Message 3 of 4
Anonymous
in reply to: rflannery

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. 😐

 

 

Message 4 of 4
rflannery
in reply to: Anonymous

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.

Post to forums  

Autodesk Design & Make Report