SetUserPref

Introduced

v1.0

Description

Sets a user preference and returns the previous setting. Some of these user preference settings correspond to the available settings in the User Preference dialog box, and some correspond to preferences that can be set from the Main Control Panel. For a list of possible settings, see UserPreference.

Note: The "AutoInspectEnabled" (siAutoInspect) preference cannot be changed permanently through scripting. For more information, see Property Editor Automatic Inspection.

Scripting Syntax

oVariant = SetUserPref( Target, Value );

Return Value

Returns previous value (last value before update) as a Variant.

Parameters

Parameter Type Description
Target UserPreference User preference to set.
Value Variant New value for user preference. These values vary depending on what you specify for the UserPreference parameter.

See UserPreference for lists of possible value types available for each UserPreference setting.

Examples

1. Python Example

# 

# 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.

# 

from win32com.client import constants as cns

app = Application

# Current value of AutoInspect

app.LogMessage( app.GetUserPref(cns.siAutoInspect) )

# Toggle the orginal value and re-log the value

app.SetUserPref( cns.siAutoInspect, not(app.GetUserPref(cns.siAutoInspect)) )

app.LogMessage( app.GetUserPref(cns.siAutoInspect) )

# 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

2. VBScript Example

' Current value of AutoInspect

Application.LogMessage GetUserPref(siAutoInspect)

' Save old setting while turning on AutoInspect and display the new value

dim prevval

prevval = SetUserPref(siAutoInspect, False)

Application.LogMessage GetUserPref(siAutoInspect)

' Restore former setting and display its value again (explicitly reverting

' back to the original value isn't necessary, as Softimage will do that automatically

' after the script has run its course)

SetUserPref siAutoInspect, prevval

Application.LogMessage GetUserPref(siAutoInspect)

' If your AutoInspect preference was enabled originally, the History Log 

' would display the following:

' 'INFO : "True"

' 'INFO : "False"

' 'INFO : "True"

3. JScript Example

// Get a sphere and switch into T, Local and X/Z modes

CreatePrim("Sphere", "NurbsSurface");

TranslateTool();

SetUserPref("3D_TRANSFO_REFERENTIAL_CHANGED", 2);

SetUserPref("3D_TRANSFO_EDITED_AXIS_CHANGED", 5);

See Also

GetUserPref Preferences.SetPreferenceValue