v3.5
システム環境変数のString値を設定したり、戻したりします。
注:Python
スクリプト言語では、環境変数の設定にこのプロパティを使用することはできません。パラメタリゼーションされたプロパティの設定を win32
拡張機能がサポートしていないためです。代わりに、下に示すように、XSIUtils の Python COM サポートの生成後に
Environment.SetItem
メソッドを使用します。
Python 2.3 以降および win32 拡張機能 1.55 以降を使用して、XSIUtils タイプ ライブラリ用の Python COM
サポートを生成できます。これにより、項目プロパティの設定が可能なSetItem( name,
value)メソッドが作成されます(Environment.SetItemを参照)。
XSIUtils をサポートする Python COM を生成するには、XSIUtils タイプライブラリの makepy.py
ユーティリティを実行します。これにより、XSIUtilsモジュールがサポートするプロパティおよびオブジェクトのメソッドの説明を含む.py
ファイルが生成されます。
' how to create and set a new environment variable
XSIUtils.Environment("MY_HOME") = XSIUtils.Environment.Item("XSI_USERHOME")
LogMessage( "my home folder: " + XSIUtils.Environment.Item("MY_HOME") )
|
# This example illustrates how to create and set a new environment variable.
# Note that the SetItem method can only be used if python 2.3 or later
# and win32 extension 1.55 or later are installed and the generated
# Python COM Support exists for the XSIUtils library.
# The Python COM support for the XSIUtils can be generated by running the makepy.py
# utility on the XSIUtils type library. This will generated .py stubs contain
# descriptions of the object's methods and properties supported by the module.
import sys
Application.LogMessage( "Python Version " + sys.version )
if sys.version_info >= (2, 3):
XSIUtils.Environment.SetItem( "MY_HOME", XSIUtils.Environment.Item("XSI_USERHOME") )
Application.LogMessage( XSIUtils.Environment.Item("MY_HOME") )
else:
Application.LogMessage( "Can't use Environment.SetItem with this version" )
|