移動先: 概要 戻り値 フラグ. 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 )