1 # ##### BEGIN GPL LICENSE BLOCK #####
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.
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.
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.
17 # ##### END GPL LICENSE BLOCK #####
22 "name": "Hotkey: 'Alt Q'",
23 "description": "Viewport Numpad Menus",
24 "author": "pitiwazou, meta-androcto",
26 "blender": (2, 80, 0),
27 "location": "Alt Q key",
30 "category": "View Numpad Pie"
34 from bpy
.types
import (
40 # Lock Camera Transforms
41 class PIE_OT_LockTransforms(Operator
):
42 bl_idname
= "object.locktransforms"
43 bl_label
= "Lock Object Transforms"
44 bl_description
= ("Enable or disable the editing of objects transforms in the 3D View\n"
45 "Needs an existing Active Object")
46 bl_options
= {'REGISTER', 'UNDO'}
49 def poll(cls
, context
):
50 return context
.active_object
is not None
52 def execute(self
, context
):
53 obj
= context
.active_object
54 if obj
.lock_rotation
[0] is False:
55 obj
.lock_rotation
[0] = True
56 obj
.lock_rotation
[1] = True
57 obj
.lock_rotation
[2] = True
58 obj
.lock_scale
[0] = True
59 obj
.lock_scale
[1] = True
60 obj
.lock_scale
[2] = True
62 elif context
.object.lock_rotation
[0] is True:
63 obj
.lock_rotation
[0] = False
64 obj
.lock_rotation
[1] = False
65 obj
.lock_rotation
[2] = False
66 obj
.lock_scale
[0] = False
67 obj
.lock_scale
[1] = False
68 obj
.lock_scale
[2] = False
73 # Pie views numpad - Q
74 class PIE_MT_ViewNumpad(Menu
):
75 bl_idname
= "PIE_MT_viewnumpad"
76 bl_label
= "Pie Views Menu"
78 def draw(self
, context
):
80 ob
= context
.active_object
81 pie
= layout
.menu_pie()
86 pie
.operator("view3d.view_axis", text
="Left", icon
='TRIA_LEFT').type = 'LEFT'
88 pie
.operator("view3d.view_axis", text
="Right", icon
='TRIA_RIGHT').type = 'RIGHT'
90 pie
.operator("view3d.view_axis", text
="Bottom", icon
='TRIA_DOWN').type = 'BOTTOM'
92 pie
.operator("view3d.view_axis", text
="Top", icon
='TRIA_UP').type = 'TOP'
94 pie
.operator("view3d.view_axis", text
="Back").type = 'BACK'
96 pie
.operator("view3d.view_axis", text
="Front").type = 'FRONT'
98 box
= pie
.split().column()
100 row
= box
.row(align
=True)
101 row
.operator("view3d.view_camera", text
="View Cam", icon
='HIDE_OFF')
102 row
.operator("view3d.camera_to_view", text
="Cam To View", icon
='NONE')
104 row
= box
.row(align
=True)
105 if context
.space_data
.lock_camera
is False:
106 row
.operator("wm.context_toggle", text
="Lock Cam To View",
107 icon
='UNLOCKED').data_path
= "space_data.lock_camera"
108 elif context
.space_data
.lock_camera
is True:
109 row
.operator("wm.context_toggle", text
="Lock Cam to View",
110 icon
='LOCKED').data_path
= "space_data.lock_camera"
112 icon_locked
= 'LOCKED' if ob
and ob
.lock_rotation
[0] is False else \
113 'UNLOCKED' if ob
and ob
.lock_rotation
[0] is True else 'LOCKED'
115 row
= box
.row(align
=True)
116 row
.operator("object.locktransforms", text
="Lock Transforms", icon
=icon_locked
)
118 row
= box
.row(align
=True)
119 row
.prop(rd
, "use_border", text
="Border")
121 box
= pie
.split().column()
123 row
= box
.row(align
=True)
124 row
.operator("view3d.view_all").center
= True
125 row
.operator("view3d.view_selected", text
="Selected")
127 row
= box
.row(align
=True)
128 row
.operator("view3d.view_persportho", text
="Persp/Ortho")
129 row
.operator("view3d.localview", text
="Local/Global")
131 row
= box
.row(align
=True)
132 row
.operator("screen.region_quadview", text
="Toggle Quad")
133 row
.operator("screen.screen_full_area", text
="Toggle Full")
138 PIE_OT_LockTransforms
,
146 bpy
.utils
.register_class(cls
)
148 wm
= bpy
.context
.window_manager
149 if wm
.keyconfigs
.addon
:
151 km
= wm
.keyconfigs
.addon
.keymaps
.new(name
='3D View Generic', space_type
='VIEW_3D')
152 kmi
= km
.keymap_items
.new('wm.call_menu_pie', 'Q', 'PRESS', alt
=True)
153 kmi
.properties
.name
= "PIE_MT_viewnumpad"
154 addon_keymaps
.append((km
, kmi
))
159 bpy
.utils
.unregister_class(cls
)
161 wm
= bpy
.context
.window_manager
162 kc
= wm
.keyconfigs
.addon
164 for km
, kmi
in addon_keymaps
:
165 km
.keymap_items
.remove(kmi
)
166 addon_keymaps
.clear()
169 if __name__
== "__main__":