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: 'Q'",
23 "description": "Viewport Numpad Menus",
24 "author": "pitiwazou, meta-androcto",
26 "blender": (2, 80, 0),
30 "category": "View Numpad Pie"
34 from bpy
.types
import (
40 # Lock Camera Transforms
41 class 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 View All Sel Glob Etc - Q
74 class PieViewallSelGlobEtc(Menu
):
75 bl_idname
= "PIE_MT_vieallselglobetc"
76 bl_label
= "Pie View All Sel Glob..."
78 def draw(self
, context
):
82 layout
.operator("view3d.view_all", text
="View All").center
= True
84 layout
.operator("view3d.view_selected", text
="View Selected")
86 layout
.operator("view3d.view_persportho", text
="Persp/Ortho", icon
='RESTRICT_VIEW_OFF')
88 layout
.operator("view3d.localview", text
="Local/Global")
90 layout
.operator("screen.region_quadview", text
="Toggle Quad View", icon
='NONE')
92 layout
.operator("wm.call_menu_pie", text
="Previous Menu", icon
='BACK').name
= "PIE_MT_viewnumpad"
94 layout
.operator("screen.screen_full_area", text
="Full Screen", icon
='FULLSCREEN_ENTER')
98 # Pie views numpad - Q
99 class PieViewNumpad(Menu
):
100 bl_idname
= "PIE_MT_viewnumpad"
101 bl_label
= "Pie Views Ortho"
103 def draw(self
, context
):
105 ob
= context
.active_object
106 pie
= layout
.menu_pie()
107 scene
= context
.scene
111 pie
.operator("view3d.view_axis", text
="Left", icon
='TRIA_LEFT').type = 'LEFT'
113 pie
.operator("view3d.view_axis", text
="Right", icon
='TRIA_RIGHT').type = 'RIGHT'
115 pie
.operator("view3d.view_axis", text
="Bottom", icon
='TRIA_DOWN').type = 'BOTTOM'
117 pie
.operator("view3d.view_axis", text
="Top", icon
='TRIA_UP').type = 'TOP'
119 pie
.operator("view3d.view_axis", text
="Front").type = 'FRONT'
121 pie
.operator("view3d.view_axis", text
="Back").type = 'BACK'
123 box
= pie
.split().column()
124 row
= box
.row(align
=True)
126 if context
.space_data
.lock_camera
is False:
127 row
.operator("wm.context_toggle", text
="Lock Cam to View",
128 icon
='UNLOCKED').data_path
= "space_data.lock_camera"
129 elif context
.space_data
.lock_camera
is True:
130 row
.operator("wm.context_toggle", text
="Lock Cam to View",
131 icon
='LOCKED').data_path
= "space_data.lock_camera"
133 row
= box
.row(align
=True)
134 row
.operator("view3d.view_camera", text
="View Cam", icon
='VISIBLE_IPO_ON')
135 row
.operator("view3d.camera_to_view", text
="Cam to view", icon
='NONE')
137 icon_locked
= 'LOCKED' if ob
and ob
.lock_rotation
[0] is False else \
138 'UNLOCKED' if ob
and ob
.lock_rotation
[0] is True else 'LOCKED'
140 row
= box
.row(align
=True)
141 row
.operator("object.locktransforms", text
="Lock Transforms", icon
=icon_locked
)
143 row
= box
.row(align
=True)
144 row
.prop(rd
, "use_border", text
="Border")
146 pie
.menu(PieViewallSelGlobEtc
.bl_idname
, text
="View Menu", icon
='NONE')
152 PieViewallSelGlobEtc
,
160 bpy
.utils
.register_class(cls
)
162 wm
= bpy
.context
.window_manager
163 if wm
.keyconfigs
.addon
:
165 km
= wm
.keyconfigs
.addon
.keymaps
.new(name
='3D View Generic', space_type
='VIEW_3D')
166 kmi
= km
.keymap_items
.new('wm.call_menu_pie', 'Q', 'PRESS')
167 kmi
.properties
.name
= "PIE_MT_viewnumpad"
168 addon_keymaps
.append((km
, kmi
))
173 bpy
.utils
.unregister_class(cls
)
175 wm
= bpy
.context
.window_manager
176 kc
= wm
.keyconfigs
.addon
178 for km
, kmi
in addon_keymaps
:
179 km
.keymap_items
.remove(kmi
)
180 addon_keymaps
.clear()
183 if __name__
== "__main__":