Changing user preferences via API

Hey Guys,

I’d like to change some of the user preferences(like “Rotate Around Selection” or “MipMaps”) via API. I’ve used the “Operator Simple” template and filled the “main” function with this:


def main(context):
     prefs = bpy.types.UserPreferencesSystem
     prefs.use_mipmaps = True

I don’t get any errors but also any satisfying results -> MipMaps remains unchecked in the user preferencies tab “System”.

Any ideas what I’m doing wrong?

ahh, I sorted it out


def main(context):
     prefs = context.user_preferences.system
     prefs.use_mipmaps = True

You can place a script in the startup folder

(C:\Users\username\AppData\Roaming\Blender Foundation\Blender\2.62\scripts\startup
I called mine user_prefs.py and it looks like this:


import bpy
def register():
    pass
bpy.context.user_preferences.filepaths.image_editor = "C:\\Users\\username\\gimp\\gimp.exe"
bpy.context.user_preferences.filepaths.texture_directory = "C:\\Users\\username\\pictures\	exture\\"
bpy.context.user_preferences.filepaths.render_output_directory = "C:\\Users\\username\\pictures\\mine\\"
bpy.context.user_preferences.filepaths.animation_player = "C:\\Users\\username\\blenders\\djv\\bin\\djv_view.exe"

When you restore factory settings and save, you’re not done. You need to close and reopen, then save, then all the scripted settings take effect and get saved. No need for an operator.