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: 'Ctrl A'",
23 "description": "Apply Transform Menu",
24 "author": "pitiwazou, meta-androcto",
26 "blender": (2, 80, 0),
27 "location": "3D View",
30 "category": "Apply Transform Pie"
34 from bpy
.types
import (
38 from bpy
.props
import EnumProperty
41 # Pie Apply Transforms - Ctrl + A
42 class PieApplyTransforms(Menu
):
43 bl_idname
= "PIE_MT_applytransforms"
44 bl_label
= "Pie Apply Transforms"
46 def draw(self
, context
):
48 pie
= layout
.menu_pie()
50 pie
.operator("apply.transformall", text
="Apply All", icon
='FREEZE')
52 pie
.operator("clear.all", text
="Clear All", icon
='NONE')
54 pie
.operator("object.duplicates_make_real", text
="Make Duplicates Real")
56 pie
.operator("apply.transformlocrotscale", text
="Rotation", icon
='NONE').option
= 'ROT'
58 pie
.operator("apply.transformlocrotscale", text
="Location", icon
='NONE').option
= 'LOC'
60 pie
.operator("apply.transformlocrotscale", text
="Scale", icon
='NONE').option
= 'SCALE'
62 pie
.operator("object.visual_transform_apply", text
="Visual Transforms")
64 pie
.menu("PIE_MT_clear_menu", text
="Clear Transform Menu")
68 class ApplyTransLocRotPie(Operator
):
69 bl_idname
= "apply.transformlocrotscale"
70 bl_label
= "Apply Transforms"
71 bl_description
= "Apply Transform: Location, Rotation or Scale"
72 bl_options
= {'REGISTER', 'UNDO'}
77 ("LOC", "Location", "Apply Location"),
78 ("ROT", "Rotation", "Apply Rotation"),
79 ("SCALE", "Scale", "Apply Scale")
84 def execute(self
, context
):
85 loc
= True if self
.option
== "LOC" else False
86 rot
= True if self
.option
== "ROT" else False
87 sca
= True if self
.option
== "SCALE" else False
88 bpy
.ops
.object.transform_apply(location
=loc
, rotation
=rot
, scale
=sca
)
94 class ApplyTransformAll(Operator
):
95 bl_idname
= "apply.transformall"
96 bl_label
= "Apply All Transforms"
97 bl_description
= "Apply Transform All"
98 bl_options
= {'REGISTER', 'UNDO'}
100 def execute(self
, context
):
101 bpy
.ops
.object.transform_apply(location
=True, rotation
=True, scale
=True)
106 class ClearMenu(Menu
):
107 bl_idname
= "PIE_MT_clear_menu"
108 bl_label
= "Clear Menu"
110 def draw(self
, context
):
112 layout
.operator("object.location_clear", text
="Clear Location", icon
='NONE')
113 layout
.operator("object.rotation_clear", text
="Clear Rotation", icon
='NONE')
114 layout
.operator("object.scale_clear", text
="Clear Scale", icon
='NONE')
115 layout
.operator("object.origin_clear", text
="Clear Origin", icon
='NONE')
119 class ClearAll(Operator
):
120 bl_idname
= "clear.all"
121 bl_label
= "Clear All"
122 bl_description
= "Clear All Transforms"
123 bl_options
= {'REGISTER', 'UNDO'}
125 def execute(self
, context
):
126 bpy
.ops
.object.location_clear()
127 bpy
.ops
.object.rotation_clear()
128 bpy
.ops
.object.scale_clear()
145 bpy
.utils
.register_class(cls
)
146 wm
= bpy
.context
.window_manager
148 if wm
.keyconfigs
.addon
:
150 km
= wm
.keyconfigs
.addon
.keymaps
.new(name
='Object Mode')
151 kmi
= km
.keymap_items
.new('wm.call_menu_pie', 'A', 'PRESS', ctrl
=True)
152 kmi
.properties
.name
= "PIE_MT_applytransforms"
153 addon_keymaps
.append((km
, kmi
))
158 bpy
.utils
.unregister_class(cls
)
160 wm
= bpy
.context
.window_manager
161 kc
= wm
.keyconfigs
.addon
163 for km
, kmi
in addon_keymaps
:
164 km
.keymap_items
.remove(kmi
)
165 addon_keymaps
.clear()
168 if __name__
== "__main__":