ジャンプ先: 概要. 戻り値. フラグ. Python 例.
cmdFileOutput([close=uint], [closeAll=boolean], [open=string], [status=uint])
注: オブジェクトの名前と引数を表す文字列は、カンマで区切る必要があります。これはシノプシスに示されていません。
cmdFileOutput は、取り消し可能、照会可能、および編集不可能です。
このコマンドは、通常はスクリプト エディタ(Script Editor)ウィンドウまたはコンソールに出力されるコマンドと結果をすべて受信したテキスト ファイルを開きます。このファイルは、正しいファイル記述子と -close、または -closeAll が明示的に指定されるまで、開いたままになります。したがって、不必要にファイルを開いたままにしないようにする必要があります。
Maya が起動してすぐログを開始にするために、起動する前に環境変数 MAYA_CMD_FILE_OUTPUT を指定することもできます。ファイル名に MAYA_CMD_FILE_OUTPUT を設定すると、ファイルが作成され、指定されたファイルに出力されます。Maya の起動後に記述子にアクセスする場合は、-query フラグと -open フラグを同時に使用します。
int | : 開いているときに、ステータスを照会またはファイルを閉じるのに使用する値(記述子)を返します。それ以外の場合は、ファイルのステータスを示すステータス コードを返します。 |
照会モードでは、戻り値のタイプは照会されたフラグに基づきます。
close, closeAll, open, status
フラグはコマンドの作成モードで表示できます
|
フラグはコマンドの編集モードで表示できます
|
フラグはコマンドの照会モードで表示できます
|
フラグに複数の引数を指定し、タプルまたはリストとして渡すことができます。
|
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 )