python
string [string...]
python は、取り消し可能、照会不可能、および編集不可能です。
このコマンドは MEL から Python スクリプトを実行します。このコマンドは Python コードのスニペットを含む文字列を受け取ります。このコードは実行され、結果が MEL に返されます。 複数の文字列を指定すると、実行前に改行とともに結合されて 1 つの複数行スクリプトになります。 ただし、Python インタプリタの制限により、結果を返すのはシングル ラインの Python スクリプトのみですので注意してください。 Python コードから返されるタイプは MEL タイプに変換されます。Python の int、float、および string 型の戻り値は対応する MEL のデータ型に変換されます。同様に、Python コードがリストを返す場合、この Python コマンドはこのリストを MEL 配列に変換できるかどうかを判断しようとします。int、float、および string の MEL 配列がサポートされています。これらの変換がいずれも不可能である場合、Python は返されたオブジェクトを文字列で表現して返します。| string[] | Python インタプリタにより入力文字列を処理した結果。 |
python( "import sys" );
// Call some python that will return a list of values. Note that we are
// calling the python command with a single python statement. We have to
// do that if we want to get a result back
//
string $version[] = python( "sys.version_info" );
// The result will be an array of strings because one of the elements will
// contain a string. Extract the major and minor parts of the version number
//
int $major = int( $version[0] );
int $minor = int( $version[1] );
// You can do multi-statement Python scripts, but there won't be a return value
python(
"import os",
"print os.environ[ 'MAYA_LOCATION' ]"
);