PasteAll.org
# ##### BEGIN GPL LICENSE BLOCK #####
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software Foundation,
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
# ##### END GPL LICENSE BLOCK #####

# How To Register Shortcut:
# (1-1)Add New Shortcut at 3D View -> 3D View(Global)
# (1-2)Change "none" to "view3d.zoom_to_mouse"
# (1-3)Register keys
# (2-1)Add New Shortcut at 3D View -> 3D View(Global)
# (2-2)Change "none" to "view3d.rotate_around_active"
# (2-3)Register keys
#
bl_info = {
"name": "Mouse Navigation Ext.",
"description": "Control Zoom To Mouse and Rotate Around Active",
"author": "khuuyj",
"version": (0,0),
"api":95182,
"blender": (2, 7, 2),
"location": "View > Zoom To Mouse / Rotate Around Active",
"warning": '', # used for warning icon and text in addons panel
"wiki_url": "",
"tracker_url": "",
"category": "3D View"}

import bpy
from bpy import *
from types import *

class VIEW3D_OT_ZoomToMouse(bpy.types.Operator):
bl_idname = "view3d.zoom_to_mouse"
bl_label = "Zoom To Mouse Pointer's Position in 3D View"
bl_description = "Zoom To Mouse Pointer's Position in 3D View"
bl_options= {'REGISTER', 'UNDO'}

@classmethod
def pole(cls, context):
return 1

def execute(self, context):
v = context.user_preferences.view
v.use_zoom_to_mouse = (v.use_zoom_to_mouse==False)
return {'FINISHED'}

class VIEW3D_OT_RotateAroundActive(bpy.types.Operator):
bl_idname = "view3d.rotate_around_active"
bl_label = "Rotate Around Active"
bl_description = "Rotate Around Active"
bl_options= {'REGISTER', 'UNDO'}

@classmethod
def pole(cls, context):
return 1

def execute(self, context):
v = context.user_preferences.view
v.use_rotate_around_active = (v.use_rotate_around_active==False)
return {'FINISHED'}

def menu_func(self,context):
layout = self.layout
layout.separator()
layout.operator(VIEW3D_OT_RotateAroundActive.bl_idname,text="Switch Rotate Around Active")
layout.operator(VIEW3D_OT_ZoomToMouse.bl_idname,text="Switch Zoom To Mouse")

def register():
bpy.utils.register_module(__name__)
bpy.types.VIEW3D_MT_view.append(menu_func)

def unregister():
bpy.types.VIEW3D_MT_view.remove(menu_func)
bpy.utils.unregister_module(__name__)


if __name__ == "__main__":
register()
  1. # ##### BEGIN GPL LICENSE BLOCK #####
  2. #
  3. #  This program is free software; you can redistribute it and/or
  4. #  modify it under the terms of the GNU General Public License
  5. #  as published by the Free Software Foundation; either version 2
  6. #  of the License, or (at your option) any later version.
  7. #
  8. #  This program is distributed in the hope that it will be useful,
  9. #  but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. #  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  11. #  GNU General Public License for more details.
  12. #
  13. #  You should have received a copy of the GNU General Public License
  14. #  along with this program; if not, write to the Free Software Foundation,
  15. #  Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  16. #
  17. # ##### END GPL LICENSE BLOCK #####
  18.  
  19. # How To Register Shortcut:
  20. #   (1-1)Add New Shortcut at 3D View -> 3D View(Global)
  21. #   (1-2)Change "none" to "view3d.zoom_to_mouse"
  22. #   (1-3)Register keys
  23. #   (2-1)Add New Shortcut at 3D View -> 3D View(Global)
  24. #   (2-2)Change "none" to "view3d.rotate_around_active"
  25. #   (2-3)Register keys
  26. #
  27. bl_info = {
  28.     "name": "Mouse Navigation Ext.",
  29.     "description": "Control Zoom To Mouse and Rotate Around Active",
  30.     "author": "khuuyj",
  31.     "version": (0,0),
  32.     "api":95182,
  33.     "blender": (2, 7, 2),
  34.     "location": "View > Zoom To Mouse / Rotate Around Active",
  35.     "warning": '', # used for warning icon and text in addons panel
  36.     "wiki_url": "",
  37.     "tracker_url": "",
  38.     "category": "3D View"}
  39.  
  40. import bpy
  41. from bpy import *
  42. from types import *
  43.  
  44. class VIEW3D_OT_ZoomToMouse(bpy.types.Operator):
  45.     bl_idname = "view3d.zoom_to_mouse"
  46.     bl_label = "Zoom To Mouse Pointer's Position in 3D View"
  47.     bl_description = "Zoom To Mouse Pointer's Position in 3D View"
  48.     bl_options= {'REGISTER', 'UNDO'}
  49.  
  50.     @classmethod
  51.     def pole(cls, context):
  52.         return 1
  53.  
  54.     def execute(self, context):
  55.         v = context.user_preferences.view
  56.         v.use_zoom_to_mouse = (v.use_zoom_to_mouse==False)
  57.         return {'FINISHED'}
  58.  
  59. class VIEW3D_OT_RotateAroundActive(bpy.types.Operator):
  60.     bl_idname = "view3d.rotate_around_active"
  61.     bl_label = "Rotate Around Active"
  62.     bl_description = "Rotate Around Active"
  63.     bl_options= {'REGISTER', 'UNDO'}
  64.  
  65.     @classmethod
  66.     def pole(cls, context):
  67.         return 1
  68.    
  69.     def execute(self, context):
  70.         v = context.user_preferences.view
  71.         v.use_rotate_around_active = (v.use_rotate_around_active==False)
  72.         return {'FINISHED'}
  73.  
  74. def menu_func(self,context):
  75.     layout = self.layout
  76.     layout.separator()
  77.     layout.operator(VIEW3D_OT_RotateAroundActive.bl_idname,text="Switch Rotate Around Active")
  78.     layout.operator(VIEW3D_OT_ZoomToMouse.bl_idname,text="Switch Zoom To Mouse")
  79.  
  80. def register():
  81.     bpy.utils.register_module(__name__)
  82.     bpy.types.VIEW3D_MT_view.append(menu_func)
  83.  
  84. def unregister():
  85.     bpy.types.VIEW3D_MT_view.remove(menu_func)
  86.     bpy.utils.unregister_module(__name__)
  87.  
  88.  
  89. if __name__ == "__main__":
  90.     register()
  91.    
go to heaven