Softimage SDK Programmer's Guide > Working with the SDK >

# Working with User Preferences

User preferences in Softimage are stored in property sets, so they can be accessed like any other object; however, there is a special class that provides easy access and some extra functionality.

Note

The "Interaction.autoinspect" preference cannot be changed permanently via scripting. See Property Editor Automatic Inspection for more information.

## Quick Access

The object provides direct access to the object through its property. From there you can browse through the or target a specific value ( and ). See the following examples:

- JScript Example: Browsing through preference via categories

- C++ Examples: Getting a specific preference value

## Restoring Defaults

The object provides the method, which allows you to restore defaults for a single preference value or all values associated to a specific . See the following example:

- Python Example: Exporting, importing, and restoring preferences

## Exporting/Importing Preferences

The object provides the and methods, which allow you to save your preferences (both native and custom) to an external file which you can either use as a backup or to deploy as part of an add-on package. These methods allow you to specify one or more categories, or nothing (which imports/exports all preferences). See the following example:

- Python Example: Exporting, importing, and restoring preferences

## Examples

### Python Example: Exporting, importing, and restoring preferences

    from win32com.client import constants
    app = Application

    # Export the current scripting preferences
    app.Preferences.Export( app.InstallationPath(constants.siFactoryPath) + "/myprefs.xsipref", "scripting" )

    # Restore the default values
    app.Preferences.RestoreDefault( "scripting" )

    # Now import back the scripting preferences
    app.Preferences.Import( app.InstallationPath(constants.siFactoryPath) + "/myprefs.xsipref" )

### C++ Examples: Getting a specific preference value

    using namespace XSI;
    Application app;
    Preferences prefs = app.GetPreferences();

    CString lang;
    prefs.GetPreferenceValue( L"scripting.language", lang );

    app.LogMessage( lang );

### JScript Example: Browsing through preference via categories

    /*
    	This example show how to navigate in preferences object
    	All categories and all preferences in each category will be printed.
    */
    var oPrefs = Application.Preferences;

    var oCategories = oPrefs.Categories;
    for (var i=0; i<oCategories.Count; i++) {
    	var oCategory = oCategories.Item(i);
    	Application.LogMessage( "The preferences for category " + oCategory + " are....." );
    	var oPrefs = oCategory.Parameters;
    	for (var j=0; j<oPrefs.Count; j++) {
    		var opref = oPrefs.Item(j);
    		Application.LogMessage( "\t-" + opref + " = " + opref.Value );
    	}
    }

    // Expected output:
    // INFO : The preferences for category preferences.animation_editor are.....
    // INFO : 	-preferences.animation_editor.track_sel = false
    // INFO : 	-preferences.animation_editor.parameter_sort = 1
    // INFO : 	-preferences.animation_editor.max_nb_curves = 0
    // INFO : 	-preferences.animation_editor.auto_select_marked = false
    // INFO : 	-preferences.animation_editor.auto_select_keyed = false
    // INFO : 	-preferences.animation_editor.always_show_root_objects = true
    // INFO : 	-preferences.animation_editor.simplified_mode = true
    // INFO : 	-preferences.animation_editor.prevent_movement_on_lmb = false
    // INFO : 	-preferences.animation_editor.translate_on_mmb = true
    // INFO : 	-preferences.animation_editor.fcurveeditor_multisel_expansion = 1
    // INFO : 	-preferences.animation_editor.dopesheet_multisel_expansion = 0
    // ...
    //
    // 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