Consider the following trivial PyMEL script. It basically calls an existing MEL function.
from pymel import *
message = "Are you sure you want to clean the scene? (Nodes will be removed.)"
do_clean = core.windows.confirmBox("Scene clean", message)
if do_clean:
result = mel.eval("MLdeleteUnused()")
print(result)
"result" contains the number of nodes removed from the scene, rather than which nodes were deleted. However, in Script Editor I see the following output when I invoke the script:
delete "edit_example_20160209_1"; # < can I get this output?
delete "edit_screenshot_1";
delete "place2dTexture1";
delete "place2dTexture2";
4 # < output from my print statement
Can I access this output so I can display it to the user (without them having to look in the Script Editor themselves)?
You can look at the way MLdeleteUnused()
works in <path_to_your_maya_install/scripts/others/MLdeleteUnused.mel
It looks like the UI version of the command is invoking a progress function that does the actual printing of results, but it doesnt return the values -- it's basically just printing them out as it goes