The Preferences object can be used to manage preferences in Softimage.
Each preference is in a category which is represented by a node under the Preferences container in the Application. To identify a preference the category must be specified as category.preference
. For example, "scripting.language"
.
There are 2 kinds of preferences: native and custom. Native preferences come with Softimage and can be viewed with the File->Preferences dialog. By default, no preferences file is created until you change the value of a preference, thereby changing the location of preference to user
. When Softimage starts it reads all .xsipref files located under the
/Data/Preferences
directory of the Factory, Workgroup and User locations (in that order), so if the value exists in both the factory and the user locations, the value in the user file will be used.
For custom preferences, you can create new preferences in a .xsipref file and you can use them in scripting. All loaded preferences are listed on the Preferences property page. You can also create a new category with UI that appears under the Preferences node.
using namespace XSI; Application app; Preferences preferences = app.GetPreferences(); CString languagepref ; preferences.GetPreferenceValue( L"scripting.language", languagepref ); app.LogMessage( languagepref );
using namespace XSI; Application app; Preferences preferences = app.GetPreferences(); CRefArray l_array; l_array = prefMgr.GetCategories(); for (int i=0; i< l_array.GetCount(); i++) { if ( l_array[i].GetName() == L"scripting") { } }
#include <xsi_preferences.h>
Public Member Functions | |
Preferences () | |
~Preferences () | |
Preferences (const CRef &in_ref) | |
Preferences (const Preferences &in_obj) | |
bool | IsA (siClassID in_ClassID) const |
siClassID | GetClassID () const |
Preferences & | operator= (const Preferences &in_obj) |
Preferences & | operator= (const CRef &in_ref) |
CRefArray | GetCategories () const |
CStatus | GetPreferenceValue (const CString &in_sPrefName, CValue &out_value) |
CStatus | SetPreferenceValue (const CString &in_sPrefName, const CValue &in_value) |
CStatus | Import (const CString &in_sFile) |
CStatus | Export (const CString &in_sFile, const CString &in_sCategories) |
CStatus | RestoreDefault (const CString &in_sPrefName) |
Preferences | ( | ) |
Default constructor.
~Preferences | ( | ) |
Default destructor.
Preferences | ( | const CRef & | in_ref | ) |
Constructor.
in_ref | constant reference object. |
Preferences | ( | const Preferences & | in_obj | ) |
Copy constructor.
in_obj | constant class object. |
bool IsA | ( | siClassID | in_ClassID | ) | const [virtual] |
Returns true if a given class type is compatible with this API class.
in_ClassID | class type. |
Reimplemented from SIObject.
siClassID GetClassID | ( | ) | const [virtual] |
Preferences& operator= | ( | const Preferences & | in_obj | ) |
Creates an object from another object. The newly created object is set to empty if the input object is not compatible.
in_obj | constant class object. |
Preferences& operator= | ( | const CRef & | in_ref | ) |
Creates an object from a reference object. The newly created object is set to empty if the input reference object is not compatible.
in_ref | constant class object. |
Reimplemented from SIObject.
CRefArray GetCategories | ( | ) | const |
Returns the value of the specified preference.
in_sPrefName | The name of the preference including the category: category.preference name |
out_value | The value returned. |
Sets the value of the specified preference.
in_sPrefName | The name of the preference including the category: category.preference name |
in_value | The value to set |
Imports a set of preferences into Softimage. All values are saved in the .xsipref under the user location. The file can contain preferences from any category. The file must be in the
.xsipref file format.
in_sFile | The file to import. |
Exports one or more categories of preferences into a .xsipref file.
in_sFile | The file to export. |
in_sCategories | The categories to export |
The category or the preference to restore to the default value. It can also be a specific preference.
in_sPrefName | The category or preference to restore. |