-
Notifications
You must be signed in to change notification settings - Fork 8
/
view3d_lock2d.py
46 lines (39 loc) · 1.3 KB
/
view3d_lock2d.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
bl_info = {
'name': 'Lock 3d navigation to 2d',
'author': 'domLysz',
'license': 'GPL',
'deps': '',
'version': (0, 1),
'blender': (2, 7, 0),
'location': 'Shortcut numpad *',
'description': '',
'warning': '',
'wiki_url': 'https://github.com/domlysz',
'tracker_url': '',
'link': '',
'support': 'COMMUNITY',
'category': 'View 3d',
}
import bpy
class LOCK2D(bpy.types.Operator):
bl_idname = "view3d.lock2d"
bl_description = 'Pan 3D view with mouse whell clic and shift to rotate'
bl_label = "Lock 2d"
def execute(self, context):
wm = bpy.context.window_manager
km = wm.keyconfigs.active.keymaps['3D View']
kmiRotate = km.keymap_items['view3d.rotate']
kmiMove = km.keymap_items['view3d.move']
kmiRotate.shift = not kmiRotate.shift
kmiMove.shift = not kmiMove.shift
return {'FINISHED'}
def register():
bpy.utils.register_class(LOCK2D)
wm = bpy.context.window_manager
km = wm.keyconfigs.active.keymaps['3D View']
kmi = km.keymap_items.new(idname='view3d.lock2d', value='PRESS', type='NUMPAD_ASTERIX', ctrl=False, alt=False, shift=False, oskey=False)
def unregister():
wm = bpy.context.window_manager
km = wm.keyconfigs.active.keymaps['3D View']
kmi = km.keymap_items.remove(km.keymap_items['view3d.lock2d'])
bpy.utils.unregister_class(LOCK2D)