How can I set Workbench (WB) user preferences via script?

Is it possible to modify the user preferences under WB --> Tools --> Options using scripting?

Answers

  • Landon Mitchell Kanner
    Landon Mitchell Kanner Member, Employee Posts: 183
    First Answer First Comment 5 Likes First Anniversary
    edited January 10

    You can use SetPreferenceValue(ObjectName,Value).

    To find the right arguments, modify the setting manually and then check the XML files here:
    %AppData%\Ansys\v{version}\UserRegFiles_{number}

    Most settings are stored in MainPreferences.XML

    If you first reset everything to defaults, it will be easier to see what has changed.

    You can use GetPreferenceValue(ObjectName) to test that you have the correct first argument before trying to figure out the second argument.

    As an example, here is how to set WB --> Tools --> Options --> Appearance --> Text Color to the color red:
    SetPreferenceValue("GraphicsTextColor","255 0 0 0") # Red
    See: https://discuss.ansys.com/discussion/2860/how-to-change-background-text-color-in-wb-options-using-scripting/p1?new=1 for more details.

    Setting options this way is not persistent. Closing Workbench and reopening will revert the settings. To make the settings persistent:
    Ansys.Core.Preference.Commands.SavePreferencesCommand.InvokeAndWait("")​