1 # SPDX-FileCopyrightText: 2016-2022 Blender Foundation
3 # SPDX-License-Identifier: GPL-2.0-or-later
6 "name": "Hotkey: 'Alt Q'",
7 "description": "Viewport Numpad Menus",
8 "author": "pitiwazou, meta-androcto",
10 "blender": (2, 80, 0),
11 "location": "Alt Q key",
14 "category": "View Numpad Pie"
18 from bpy
.types
import (
24 # Lock Camera Transforms
25 class PIE_OT_LockTransforms(Operator
):
26 bl_idname
= "object.locktransforms"
27 bl_label
= "Lock Object Transforms"
29 "Enable or disable the editing of objects transforms in the 3D View\n"
30 "Needs an existing Active Object"
32 bl_options
= {'REGISTER', 'UNDO'}
35 def poll(cls
, context
):
36 return context
.active_object
is not None
38 def execute(self
, context
):
39 obj
= context
.active_object
40 if obj
.lock_rotation
[0] is False:
41 obj
.lock_rotation
[0] = True
42 obj
.lock_rotation
[1] = True
43 obj
.lock_rotation
[2] = True
44 obj
.lock_scale
[0] = True
45 obj
.lock_scale
[1] = True
46 obj
.lock_scale
[2] = True
48 elif context
.object.lock_rotation
[0] is True:
49 obj
.lock_rotation
[0] = False
50 obj
.lock_rotation
[1] = False
51 obj
.lock_rotation
[2] = False
52 obj
.lock_scale
[0] = False
53 obj
.lock_scale
[1] = False
54 obj
.lock_scale
[2] = False
59 # Pie views numpad - Q
60 class PIE_MT_ViewNumpad(Menu
):
61 bl_idname
= "PIE_MT_viewnumpad"
62 bl_label
= "Pie Views Menu"
64 def draw(self
, context
):
66 ob
= context
.active_object
67 pie
= layout
.menu_pie()
72 pie
.operator("view3d.view_axis", text
="Left", icon
='TRIA_LEFT').type = 'LEFT'
74 pie
.operator("view3d.view_axis", text
="Right", icon
='TRIA_RIGHT').type = 'RIGHT'
76 pie
.operator("view3d.view_axis", text
="Bottom", icon
='TRIA_DOWN').type = 'BOTTOM'
78 pie
.operator("view3d.view_axis", text
="Top", icon
='TRIA_UP').type = 'TOP'
80 pie
.operator("view3d.view_axis", text
="Back").type = 'BACK'
82 pie
.operator("view3d.view_axis", text
="Front").type = 'FRONT'
84 box
= pie
.split().column()
86 row
= box
.row(align
=True)
87 row
.operator("view3d.view_camera", text
="View Cam", icon
='HIDE_OFF')
88 row
.operator("view3d.camera_to_view", text
="Cam To View", icon
='NONE')
90 row
= box
.row(align
=True)
91 if context
.space_data
.lock_camera
is False:
92 row
.operator("wm.context_toggle", text
="Lock Cam To View",
93 icon
='UNLOCKED').data_path
= "space_data.lock_camera"
94 elif context
.space_data
.lock_camera
is True:
95 row
.operator("wm.context_toggle", text
="Lock Cam to View",
96 icon
='LOCKED').data_path
= "space_data.lock_camera"
98 icon_locked
= 'LOCKED' if ob
and ob
.lock_rotation
[0] is False else \
99 'UNLOCKED' if ob
and ob
.lock_rotation
[0] is True else 'LOCKED'
101 row
= box
.row(align
=True)
102 row
.operator("object.locktransforms", text
="Lock Transforms", icon
=icon_locked
)
104 row
= box
.row(align
=True)
105 row
.prop(rd
, "use_border", text
="Border")
107 box
= pie
.split().column()
109 row
= box
.row(align
=True)
110 row
.operator("view3d.view_all").center
= True
111 row
.operator("view3d.view_selected", text
="Selected")
113 row
= box
.row(align
=True)
114 row
.operator("view3d.view_persportho", text
="Persp/Ortho")
115 row
.operator("view3d.localview", text
="Local/Global")
117 row
= box
.row(align
=True)
118 row
.operator("screen.region_quadview", text
="Toggle Quad")
119 row
.operator("screen.screen_full_area", text
="Toggle Full")
124 PIE_OT_LockTransforms
,
132 bpy
.utils
.register_class(cls
)
134 wm
= bpy
.context
.window_manager
135 if wm
.keyconfigs
.addon
:
137 km
= wm
.keyconfigs
.addon
.keymaps
.new(name
='3D View Generic', space_type
='VIEW_3D')
138 kmi
= km
.keymap_items
.new('wm.call_menu_pie', 'Q', 'PRESS', alt
=True)
139 kmi
.properties
.name
= "PIE_MT_viewnumpad"
140 addon_keymaps
.append((km
, kmi
))
145 bpy
.utils
.unregister_class(cls
)
147 wm
= bpy
.context
.window_manager
148 kc
= wm
.keyconfigs
.addon
150 for km
, kmi
in addon_keymaps
:
151 km
.keymap_items
.remove(kmi
)
152 addon_keymaps
.clear()
155 if __name__
== "__main__":