Import images: add file handler
[blender-addons.git] / space_view3d_pie_menus / pie_apply_transform_menu.py
blob14e155ffcbdb8e018eeec92687d01c3f23731759
1 # SPDX-FileCopyrightText: 2016-2022 Blender Foundation
3 # SPDX-License-Identifier: GPL-2.0-or-later
5 bl_info = {
6 "name": "Hotkey: 'Ctrl A'",
7 "description": "Apply Transform Menu",
8 "author": "pitiwazou, meta-androcto",
9 "version": (0, 1, 1),
10 "blender": (2, 80, 0),
11 "location": "3D View",
12 "warning": "",
13 "doc_url": "",
14 "category": "Apply Transform Pie"
17 import bpy
18 from bpy.types import (
19 Menu,
20 Operator,
22 from bpy.props import EnumProperty
25 # Pie Apply Transforms - Ctrl + A
26 class PIE_MT_PieApplyTransforms(Menu):
27 bl_idname = "PIE_MT_applytransforms"
28 bl_label = "Pie Apply Transforms"
30 def draw(self, context):
31 layout = self.layout
32 pie = layout.menu_pie()
33 # 4 - LEFT
34 pie.operator("object.visual_transform_apply", text="Apply Visual")
35 # 6 - RIGHT
36 props = pie.operator("object.transform_apply", text="Apply All")
37 props.location, props.rotation, props.scale = (True, True, True)
38 # 2 - BOTTOM
39 props = pie.operator("object.transform_apply", text="Rotation/Scale")
40 props.location, props.rotation, props.scale = (False, True, True)
41 # 8 - TOP
42 props = pie.operator("object.transform_apply", text="Rotation")
43 props.location, props.rotation, props.scale = (False, True, False)
44 # 7 - TOP - LEFT
45 props = pie.operator("object.transform_apply", text="Location")
46 props.location, props.rotation, props.scale = (True, False, False)
47 # 9 - TOP - RIGHT
48 props = pie.operator("object.transform_apply", text="Scale")
49 props.location, props.rotation, props.scale = (False, False, True)
50 # 1 - BOTTOM - LEFT
51 pie.operator("object.duplicates_make_real", text="Make Instances Real")
52 # 3 - BOTTOM - RIGHT
53 pie.menu("PIE_MT_clear_menu", text="Clear Transform Menu")
56 # Clear Menu
57 class PIE_MT_ClearMenu(Menu):
58 bl_idname = "PIE_MT_clear_menu"
59 bl_label = "Clear Menu"
61 def draw(self, context):
62 layout = self.layout
63 layout.operator("clear.all", text="Clear All", icon='NONE')
64 layout.operator("object.location_clear", text="Clear Location", icon='NONE')
65 layout.operator("object.rotation_clear", text="Clear Rotation", icon='NONE')
66 layout.operator("object.scale_clear", text="Clear Scale", icon='NONE')
67 layout.operator("object.origin_clear", text="Clear Origin", icon='NONE')
70 # Clear all
71 class PIE_OT_ClearAll(Operator):
72 bl_idname = "clear.all"
73 bl_label = "Clear All"
74 bl_description = "Clear All Transforms"
75 bl_options = {'REGISTER', 'UNDO'}
77 def execute(self, context):
78 bpy.ops.object.location_clear()
79 bpy.ops.object.rotation_clear()
80 bpy.ops.object.scale_clear()
81 return {'FINISHED'}
84 classes = (
85 PIE_MT_PieApplyTransforms,
86 PIE_MT_ClearMenu,
87 PIE_OT_ClearAll,
90 addon_keymaps = []
93 def register():
94 for cls in classes:
95 bpy.utils.register_class(cls)
96 wm = bpy.context.window_manager
98 if wm.keyconfigs.addon:
99 # Apply Transform
100 km = wm.keyconfigs.addon.keymaps.new(name='Object Mode')
101 kmi = km.keymap_items.new('wm.call_menu_pie', 'A', 'PRESS', ctrl=True)
102 kmi.properties.name = "PIE_MT_applytransforms"
103 addon_keymaps.append((km, kmi))
106 def unregister():
107 for cls in classes:
108 bpy.utils.unregister_class(cls)
110 wm = bpy.context.window_manager
111 kc = wm.keyconfigs.addon
112 if kc:
113 for km, kmi in addon_keymaps:
114 km.keymap_items.remove(kmi)
115 addon_keymaps.clear()
118 if __name__ == "__main__":
119 register()