Go to: Synopsis. Return value. Flags. Python examples.
cmdFileOutput([close=uint], [closeAll=boolean], [open=string], [status=uint])
Note: Strings representing object names and arguments must be separated by commas. This is not depicted in the synopsis.
cmdFileOutput is undoable, queryable, and NOT editable.
This command will open a text file to receive all of the commands and results that normally get printed to the Script Editor window or console. The file will stay open until an explicit -close with the correct file descriptor or a -closeAll, so care should be taken not to leave a file open.To enable logging to commence as soon as Maya starts up, the environment variable MAYA_CMD_FILE_OUTPUT may be specified prior to launching Maya. Setting MAYA_CMD_FILE_OUTPUT to a filename will create and output to that given file. To access the descriptor after Maya has started, use the -query and -open flags together.
| int | : On open, returns a value (descriptor) that can be used to query the status or close the file. Otherwise, a status code indicating status of file |
In query mode, return type is based on queried flag.
| Long name (short name) | Argument types | Properties | ||
|---|---|---|---|---|
close(c)
|
uint
|
|
||
|
||||
closeAll(ca)
|
boolean
|
|
||
|
||||
open(o)
|
string
|
|
||
|
||||
status(s)
|
uint
|
|
||
|
||||
import maya.cmds as cmds cmds.cmdFileOutput( o='dbOutput.txt' ) # Result: 1 # print( 'This message is in the file\n' ) # This message is in the file cmds.cmdFileOutput( s=1 ) # Result: 0 # cmds.cmdFileOutput( s=2 ) # Result: -3 # cmds.cmdFileOutput( c=1 ) # Result: 0 # # Notice that the 'This message is in the file' string is in the file, # as are all of the entered commands and the # '# Result: ...' lines, etc. # Turn on logging to a file on Maya startup so as to log all error # messages which happen on startup. # # Set the environment variable MAYA_CMD_FILE_OUTPUT to "trace.txt" # Start up Maya # Messages should now be logged to the file "trace.txt" as well as the # script editor window. # Turn off logging to the filename specified by $MAYA_CMD_FILE_OUTPUT # after Maya has completed startup. # import os traceFile = os.environ[ "MAYA_CMD_FILE_OUTPUT" ] descriptor = cmds.cmdFileOutput( q=True, o=traceFile ) if -1 != descriptor: cmds.cmdFileOutput( close=descriptor )