# Change settings like 'limit selection to visible' or 'trackball rotation' with python

My original intention is to transfer settings with a .blend file, but as far as I know, ordinary blends don't store everything.

I have tried to understand the API documentation for a while now, yet since I'm not a developer, I have a hard time closing the 'assumed knowledge' gap.

So far I've found bpy.types.SpaceView3D.use_occlude_geometry but no sample code or link and I just get error messages.

Blender's Info window output isn't revealing much either when I push the button manually, at least not to the untrained eye. bpy.data.screens["Default"].(null) = False

So, here are my needs:

• Switch MMB with SHIFT-MMB
• Turn on trackball rotation for viewport rotation
• Disable Limit selection to visible

• Switch MMB with SHIFTMMB

view3d_km = bpy.context.window_manager.keyconfigs['Blender'].keymaps['3D View']
view3d_km.keymap_items['view3d.rotate'].map_type = 'MOUSE'
view3d_km.keymap_items['view3d.rotate'].type = 'MIDDLEMOUSE'
view3d_km.keymap_items['view3d.rotate'].shift = True

• Turn on trackball rotation for MMB

bpy.context.user_preferences.inputs.view_rotate_method = 'TRACKBALL'

• Disable Limit selection to visible

for scr in bpy.data.screens:
for area in scr.areas:
for space in area.spaces:
if space.type == 'VIEW_3D':
space.use_occlude_geometry = True

• This really helps. It seems to be enough to change the .shift values of view3D.rotate and view3d.move – Haunt_House Aug 24 '13 at 5:03
• Yep - if it's already set up to use middlemouse, which it usually will be. – z0r Aug 24 '13 at 5:23

Not sure on the first one (you want to swap rotate with pan?) but...

Turn on trackball rotation:

bpy.context.user_preferences.inputs.view_rotate_method = 'TRACKBALL'


Disable Limit selection to visible in all 3D Views in all screens:

for screen in bpy.data.screens:
for area in screen.areas:
if area.type == 'VIEW_3D':
area.spaces[0].use_occlude_geometry = False

• Since Gimp and basically all 2D areas in Blender use MMB to pan, and since I pan more than I rotate and because it once was a simple toggle button in Blender, I use MMB to pan in the 3D view. My muscle memory likes it. – Haunt_House Aug 24 '13 at 4:49
• This is a great example how four lines of code give me a clear picture instantly. Thank you – Haunt_House Aug 24 '13 at 5:04