移動先: 概要 戻り値 フラグ. 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
ロング ネーム(ショート ネーム) 引数型 プロパティ
open(o) string createquery
指定した書き込み用のファイルを開きます(書き込み可能な該当するファイルがあれば、上書きされます)。正常に開けば、値が返されてステータスが照会されファイルが閉じます。ファイルを開いて書き込むことができない場合、-1 が返されます。-open フラグは、照会モードでも指定できます。照会モードでは、指定ファイルが開いている場合はその記述子が、開いていない場合は -1 が返されます。この方法を使用すると、特定のファイルが開いているかどうかを簡単に確認できます。

このフラグは照会モードでは値が必要になります。

status(s) uint createquery
指定した記述子のステータスを照会します。該当するファイルがなければ -3 が、ファイルが開かなければ -2 が、エラーが発生すれば -1 が、ファイルが書き込みできる状態であれば 0 が返されます。
close(c) uint create
指定した記述子に対応するファイルを閉じます。 ファイルが存在しなければ、-3 が返されます。エラーの場合 -1、正常に閉じたら 0 が返されます。
closeAll(ca) boolean create
開いているファイルをすべて閉じます。

: コマンドの作成モードで使用可能なフラグ : コマンドの編集モードで使用可能なフラグ
: コマンドの照会モードで使用可能なフラグ : タプルまたはリストとして渡された複数の引数を持てるフラグ

Python 例

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 )