View Full Version : Print to the Command Response?
10 October 2007, 08:41 PM
Is there a way to print to the command response? Ie, the little blue bar at the bottom of Maya? I'd like to be able to have functions print there because if my function needs to throw an error, it does not get seen down there if i simply use print 'error'.
10 October 2007, 08:56 PM
Note that you can also print stuff with the "warning" (magenta) and/or "error"(red) command.
I think the blue bar is controlled by progressBar ( not sure if spelled correct ). Since sometimes users hide the command line and/or the Help Line I use the confirmDialog command if I want to really let the user know of some issue.
Hope this helps
10 October 2007, 09:17 PM
Is there a python version? Im getting a nasty recursive error when i try to use cmds.eval to run the error/warning mel function.
Is giving me a nasty error.
10 October 2007, 05:18 AM
Not sure it's possible. from the docs:
"MEL has its own warning and error message reporting mechanisms integrated with Maya message reporting. This includes color feedback on the command line. Python comes with system modules that provide warning and error reporting functions; however, these are not integrated into Maya and do not provide color feedback in the command line."
What I get from that snippet, is that it might be better to raise exceptions anyway rather than print errors, since that is kind of the Python way, and there's lots of good error handling there.
10 October 2007, 06:09 AM
I'll look into that then, im new to python as well. My python experience is only from XSI, and now Maya. I don't know much about it beyond scripting, since any real programming i'v done has been in C#/C++.
10 October 2007, 11:21 AM
not sure why you got that error... could maybe be an...
syntax error... e.g be eval("error \"test\"");
or eval error "test"; without no ()-thingie...
however I also got it working without the mc. thingie
using eval(`error "test"`);
if you e.g. want to printout code to the command feedback window...
you can also use evalEcho in your script where you want the result shown there...
or other place spit out the result in e.g. the script editor...
evalEcho("string $App =( \""+(`about -a`)+" "+ (`about -v`)+"\")"); //lol also produces an error in the process
catch or catchQuiet might also be quite useful... if you want to handle errors... :)
and e.g. make the user aware of it...
however I would as Buexe also mentions suggest using an confirmdialog or other kind of popup window thingie...
hope it helps a bit... :)
03 March 2008, 04:29 PM
@Zeusbwr: eval is a mel based, not command based
mc.eval('error "test"')should rather be:
import maya.mel as mel
hope my thoughts are heading the right direction here,
03 March 2008, 04:29 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.