Preferences

Object Hierarchy | 関連する C++クラス:Preferences

継承

SIObject

Preferences

導入

v4.0

詳細

Preferences オブジェクトは、Softimage のプリファレンスを管理するために使用します。各プリファレンスは、アプリケーションの下にある Preferences オブジェクトのさらに下にあるノードによって表されるカテゴリに含まれます。プリファレンスを識別するために、必ず分類を使用して(category.preference)のように指定します(例:"scripting.language")。

プリファレンスには、ネイティブとカスタムの 2種類があります。ネイティブ設定は Softimage に含まれており、[ファイル]>[設定]ダイアログで表示することができます。すべての初期設定値は、出荷時のデフォルトで設定されています。ユーザが設定の値を変更する場合、新しい値は、デフォルトの.xsiprefファイルに格納されます。このファイルは¥Data¥Preferenceディレクトリにあり、出荷時の設定の値は上書きされます。

カスタム設定では、.xsipref ファイル内で新しい設定を作成できます。ただし、この方法で作成された設定は UIがなく、スクリプトからのみアクセスできます。

また、CustomPropertyオブジェクトを作成すること、およびInstallCustomPreferencesを呼び出すことによってもカスタム設定は作成できます。このようなカスタム設定を削除す唯一の方法は、¥Data¥Preferences ディレクトリにある関連した Preset ファイルを削除することです。

注:ネイティブ設定とは異なり、この方法で作成されたカスタム設定はWorkgroupからロードできます。

パラメータタイプのサブセット(siInt4、siString、siBool、および SiDouble)のみが Custom Preferences でサポートされます(「siVariantType」を参照)。

多くのカスタムプラグインでは、ユーザインターフェイスを提供する方法として CustomProperty を使用します。たとえば、データを書き出すプラグインでは、CustomPropertyでInspectObjを呼び出すことにより、ユーザが出力ファイルとその他の設定を選択できます。カスタム設定としてこのようなCustomPropertyをインストールすると、値が 1 つのセッションから次のセッションに渡され、オブジェクトは現在のシーンに混在されず情報をシーン Explorer の Preferenceセクションで一括管理されるため、便利です。ただし、サポートされているパラメータタイプに制限があるため、プラグイン内から直接SavePresetおよびLoadPresetを呼び出すことにより同じことを行おうとすると、よりフレキシブルになります。

メソッド

Export GetPreferenceValue Import IsClassOfオペレータ
IsEqualToオペレータ RestoreDefault SaveChanges SetPreferenceValue

プロパティ

Application Categories Categories FullNameオペレータ
Help Nameオペレータ NestedObjects Origin
OriginPath Parent Typeオペレータ  
       

1. Python の例

from win32com.client import constants as cns
app = Application
# Get the preferences object on the application
oPrefs = app.Preferences
# Show the current language
app.LogMessage(oPrefs.GetPreferenceValue ("scripting.language"))
# or
app.LogMessage(oPrefs.Categories("scripting").Language.Value)
# Export all data_management preferences
oPrefs.Export( XSIUtils.BuildPath(app.InstallationPath(cns.siFactoryPath), "myDMprefs.xsipref"), "data_management")
# Now reset all preferences of the category data_management
oPrefs.RestoreDefault("data_management")
# Expected results:
# INFO : Python
# INFO : Python

2. JScript の例

/* 
        This example demonstrates how to temporarily change the user's
        AutoInspect preference (if enabled, property pages always pop
        up for objects newly created via command). It also illustrates
        how Softimage automatically reverts any scripting change to this 
        preference after the script runs.
*/
var app = Application;
// Current value of AutoInspect
app.LogMessage( app.Preferences.GetPreferenceValue("Interaction.autoinspect") );
// Toggle the orginal value and re-log the value
app.Preferences.SetPreferenceValue( 
        "Interaction.autoinspect", 
        !app.Preferences.GetPreferenceValue("Interaction.autoinspect") 
);
app.LogMessage( app.Preferences.GetPreferenceValue("Interaction.autoinspect") );
// If your AutoInspect preference was enabled originally, the History Log 
// would display the following:
// INFO : True
// INFO : False
// VERBOSE : Restoring preference changed by script: Interaction.autoinspect
// If your AutoInspect preference was disabled originally, the History Log 
// would display the following:
// INFO : False
// INFO : True
// VERBOSE : Restoring preference changed by script: Interaction.autoinspect

3. VBScript の例

' This example show how to navigate in preferences object
' All categories and all preferences in each category will be printed.
set oPrefs = Application.Preferences
set oCategories = oPrefs.categories
For each oCategory in oCategories
Application.LogMessage "The preferences for category " & oCategory & " are:"
set oPreferences = oCategory.Parameters
For each oPref in oPreferences
Application.LogMessage "   -" & oPref & " = " & oPref.Value
Next
Next
' The script logs information like the following:
' ....
' INFO : The preferences for category preferences.units are:
' INFO :    -preferences.units.colorspace = 1
' INFO :    -preferences.units.length = 2
' INFO :    -preferences.units.angle = 2
' INFO :    -preferences.units.time = 2
' INFO :    -preferences.units.mass = 2
' ....

関連項目

XSIApplication.Preferences InstallCustomPreferences SetUserPref GetUserPref UserPreference Working with User Preferences Property Editor Automatic Inspection