Sun Position: fix error in HDRI mode when no env tex is selected
[blender-addons.git] / space_view3d_pie_menus / pie_apply_transform_menu.py
blob68371aa565ed8df506bf16907104217103e408d7
1 # SPDX-License-Identifier: GPL-2.0-or-later
3 bl_info = {
4 "name": "Hotkey: 'Ctrl A'",
5 "description": "Apply Transform Menu",
6 "author": "pitiwazou, meta-androcto",
7 "version": (0, 1, 1),
8 "blender": (2, 80, 0),
9 "location": "3D View",
10 "warning": "",
11 "doc_url": "",
12 "category": "Apply Transform Pie"
15 import bpy
16 from bpy.types import (
17 Menu,
18 Operator,
20 from bpy.props import EnumProperty
23 # Pie Apply Transforms - Ctrl + A
24 class PIE_MT_PieApplyTransforms(Menu):
25 bl_idname = "PIE_MT_applytransforms"
26 bl_label = "Pie Apply Transforms"
28 def draw(self, context):
29 layout = self.layout
30 pie = layout.menu_pie()
31 # 4 - LEFT
32 pie.operator("object.visual_transform_apply", text="Apply Visual")
33 # 6 - RIGHT
34 props = pie.operator("object.transform_apply", text="Apply All")
35 props.location, props.rotation, props.scale = (True, True, True)
36 # 2 - BOTTOM
37 props = pie.operator("object.transform_apply", text="Rotation/Scale")
38 props.location, props.rotation, props.scale = (False, True, True)
39 # 8 - TOP
40 props = pie.operator("object.transform_apply", text="Rotation")
41 props.location, props.rotation, props.scale = (False, True, False)
42 # 7 - TOP - LEFT
43 props = pie.operator("object.transform_apply", text="Location")
44 props.location, props.rotation, props.scale = (True, False, False)
45 # 9 - TOP - RIGHT
46 props = pie.operator("object.transform_apply", text="Scale")
47 props.location, props.rotation, props.scale = (False, False, True)
48 # 1 - BOTTOM - LEFT
49 pie.operator("object.duplicates_make_real", text="Make Instances Real")
50 # 3 - BOTTOM - RIGHT
51 pie.menu("PIE_MT_clear_menu", text="Clear Transform Menu")
54 # Clear Menu
55 class PIE_MT_ClearMenu(Menu):
56 bl_idname = "PIE_MT_clear_menu"
57 bl_label = "Clear Menu"
59 def draw(self, context):
60 layout = self.layout
61 layout.operator("clear.all", text="Clear All", icon='NONE')
62 layout.operator("object.location_clear", text="Clear Location", icon='NONE')
63 layout.operator("object.rotation_clear", text="Clear Rotation", icon='NONE')
64 layout.operator("object.scale_clear", text="Clear Scale", icon='NONE')
65 layout.operator("object.origin_clear", text="Clear Origin", icon='NONE')
68 # Clear all
69 class PIE_OT_ClearAll(Operator):
70 bl_idname = "clear.all"
71 bl_label = "Clear All"
72 bl_description = "Clear All Transforms"
73 bl_options = {'REGISTER', 'UNDO'}
75 def execute(self, context):
76 bpy.ops.object.location_clear()
77 bpy.ops.object.rotation_clear()
78 bpy.ops.object.scale_clear()
79 return {'FINISHED'}
82 classes = (
83 PIE_MT_PieApplyTransforms,
84 PIE_MT_ClearMenu,
85 PIE_OT_ClearAll,
88 addon_keymaps = []
91 def register():
92 for cls in classes:
93 bpy.utils.register_class(cls)
94 wm = bpy.context.window_manager
96 if wm.keyconfigs.addon:
97 # Apply Transform
98 km = wm.keyconfigs.addon.keymaps.new(name='Object Mode')
99 kmi = km.keymap_items.new('wm.call_menu_pie', 'A', 'PRESS', ctrl=True)
100 kmi.properties.name = "PIE_MT_applytransforms"
101 addon_keymaps.append((km, kmi))
104 def unregister():
105 for cls in classes:
106 bpy.utils.unregister_class(cls)
108 wm = bpy.context.window_manager
109 kc = wm.keyconfigs.addon
110 if kc:
111 for km, kmi in addon_keymaps:
112 km.keymap_items.remove(kmi)
113 addon_keymaps.clear()
116 if __name__ == "__main__":
117 register()