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 #####
21 'author': 'Daniel Salazar <zanqdo@gmail.com>',
23 "blender": (2, 63, 0),
24 'location': 'Select a Mesh/Lattice/Curve: Tool Shelf > AnimAll panel',
25 'description': 'Allows animation of mesh, lattice and curve data (Shape Keys, VCols, VGroups, UVs, Points, Radius, Tilt)',
27 'wiki_url': 'http://wiki.blender.org/index.php/Extensions:2.6/Py/Scripts/Animation/AnimAll',
28 'tracker_url': 'http://projects.blender.org/tracker/index.php?'\
29 'func=detail&aid=24874',
30 'category': 'Animation'}
32 """-------------------------------------------------------------------------
33 Thanks to Campbell Barton and Joshua Leung for hes API additions and fixes
34 Daniel 'ZanQdo' Salazar
36 Rev 0.1 initial release (animate Mesh points)
37 Rev 0.2 added support for animating UVs, VCols, VGroups
38 Rev 0.3 added support for animating Lattice points
39 Rev 0.4 added support for ShapeKey layer animation, removed support
40 for direct point animation since this new aproach is much stronger
41 and inline with the animation system
42 Rev 0.5 merged curve animation features from rotobezier and ported to new bmesh API
43 -------------------------------------------------------------------------"""
46 from bpy
.props
import *
50 # Property Definitions
52 bpy
.types
.WindowManager
.key_shape
= BoolProperty(
54 description
="Insert keyframes on active Shape Key layer",
57 bpy
.types
.WindowManager
.key_uvs
= BoolProperty(
59 description
="Insert keyframes on active UV coordinates",
62 bpy
.types
.WindowManager
.key_vcols
= BoolProperty(
64 description
="Insert keyframes on active Vertex Color values",
67 bpy
.types
.WindowManager
.key_vgroups
= BoolProperty(
69 description
="Insert keyframes on active Vertex Group values",
72 bpy
.types
.WindowManager
.key_points
= BoolProperty(
74 description
="Insert keyframes on point locations",
77 bpy
.types
.WindowManager
.key_radius
= BoolProperty(
79 description
="Insert keyframes on point radius (Shrink/Fatten)",
82 bpy
.types
.WindowManager
.key_tilt
= BoolProperty(
84 description
="Insert keyframes on point tilt",
90 class VIEW3D_PT_animall(bpy
.types
.Panel
):
92 bl_space_type
= 'VIEW_3D'
93 bl_region_type
= 'TOOLS'
95 bl_options
= {'DEFAULT_CLOSED'}
96 # show this addon only in the Camera-Data-Panel
98 def poll(self
, context
):
99 if context
.active_object
:
100 return context
.active_object
.type == 'MESH'\
101 or context
.active_object
.type == 'LATTICE'\
102 or context
.active_object
.type == 'CURVE'
105 def draw(self
, context
):
107 Obj
= context
.active_object
110 col
= layout
.column(align
=True)
113 if Obj
.type == 'LATTICE':
114 row
.prop(context
.window_manager
, "key_shape")
116 elif Obj
.type == 'MESH':
117 row
.prop(context
.window_manager
, "key_shape")
118 row
.prop(context
.window_manager
, "key_uvs")
120 row
.prop(context
.window_manager
, "key_vcols")
121 row
.prop(context
.window_manager
, "key_vgroups")
123 elif Obj
.type == 'CURVE':
124 row
.prop(context
.window_manager
, "key_points")
125 row
.prop(context
.window_manager
, "key_radius")
127 row
.prop(context
.window_manager
, "key_tilt")
130 row
.operator('anim.insert_keyframe_animall', icon
='KEY_HLT')
131 row
.operator('anim.delete_keyframe_animall', icon
='KEY_DEHLT')
133 row
.operator('anim.clear_animation_animall', icon
='X')
135 if Obj
.type != 'CURVE' and context
.window_manager
.key_shape
:
137 ShapeKey
= Obj
.active_shape_key
139 split
= layout
.split()
143 row
.label(ShapeKey
.name
, icon
='SHAPEKEY_DATA')
144 row
.prop(ShapeKey
, "value", text
="")
145 row
.prop(Obj
, "show_only_shape_key", text
="")
147 row
.label('No active ShapeKey', icon
='INFO')
150 class ANIM_OT_insert_keyframe_animall(bpy
.types
.Operator
):
152 bl_idname
= 'anim.insert_keyframe_animall'
153 bl_description
= 'Insert a Keyframe'
154 bl_options
= {'REGISTER', 'UNDO'}
158 def invoke(self
, context
, event
):
160 self
.execute(context
)
165 def execute(op
, context
):
167 Obj
= context
.active_object
169 if Obj
.type == 'MESH':
171 if context
.mode
== 'EDIT_MESH':
173 bpy
.ops
.object.editmode_toggle()
177 if context
.window_manager
.key_shape
:
178 if Obj
.active_shape_key
:
179 for Point
in Obj
.active_shape_key
.data
:
180 Point
.keyframe_insert('co')
182 if context
.window_manager
.key_vgroups
:
183 for Vert
in Data
.vertices
:
184 for Group
in Vert
.groups
:
185 Group
.keyframe_insert('weight')
187 if context
.window_manager
.key_uvs
:
188 for UV
in Data
.uv_layers
.active
.data
:
189 UV
.keyframe_insert('uv')
191 if context
.window_manager
.key_vcols
:
192 for VColLayer
in Data
.vertex_colors
:
193 if VColLayer
.active
: # only insert in active VCol layer
194 for Data
in VColLayer
.data
:
195 Data
.keyframe_insert('color')
198 bpy
.ops
.object.editmode_toggle()
200 if Obj
.type == 'LATTICE':
202 if context
.mode
!= 'OBJECT':
204 bpy
.ops
.object.editmode_toggle()
206 if context
.window_manager
.key_shape
:
207 if Obj
.active_shape_key
:
208 for Point
in Obj
.active_shape_key
.data
:
209 Point
.keyframe_insert('co')
212 bpy
.ops
.object.editmode_toggle()
214 if Obj
.type == 'CURVE':
216 if context
.mode
!= 'OBJECT':
218 bpy
.ops
.object.editmode_toggle()
222 for Spline
in Data
.splines
:
223 if Spline
.type == 'BEZIER':
224 for CV
in Spline
.bezier_points
:
225 if context
.window_manager
.key_points
:
226 CV
.keyframe_insert('co')
227 CV
.keyframe_insert('handle_left')
228 CV
.keyframe_insert('handle_right')
229 if context
.window_manager
.key_radius
:
230 CV
.keyframe_insert('radius')
231 if context
.window_manager
.key_tilt
:
232 CV
.keyframe_insert('tilt')
234 elif Spline
.type == 'NURBS':
235 for CV
in Spline
.points
:
236 if context
.window_manager
.key_points
:
237 CV
.keyframe_insert('co')
238 if context
.window_manager
.key_radius
:
239 CV
.keyframe_insert('radius')
240 if context
.window_manager
.key_tilt
:
241 CV
.keyframe_insert('tilt')
244 bpy
.ops
.object.editmode_toggle()
250 class ANIM_OT_delete_keyframe_animall(bpy
.types
.Operator
):
252 bl_idname
= 'anim.delete_keyframe_animall'
253 bl_description
= 'Delete a Keyframe'
254 bl_options
= {'REGISTER', 'UNDO'}
258 def invoke(self
, context
, event
):
260 self
.execute(context
)
265 def execute(op
, context
):
267 Obj
= context
.active_object
269 if Obj
.type == 'MESH':
271 if context
.mode
== 'EDIT_MESH':
273 bpy
.ops
.object.editmode_toggle()
277 if context
.window_manager
.key_shape
:
278 if Obj
.active_shape_key
:
279 for Point
in Obj
.active_shape_key
.data
:
280 Point
.keyframe_delete('co')
282 if context
.window_manager
.key_vgroups
:
283 for Vert
in Data
.vertices
:
284 for Group
in Vert
.groups
:
285 Group
.keyframe_delete('weight')
287 if context
.window_manager
.key_uvs
:
288 for UV
in Data
.uv_layers
.active
.data
:
289 UV
.keyframe_delete('uv')
291 if context
.window_manager
.key_vcols
:
292 for VColLayer
in Data
.vertex_colors
:
293 if VColLayer
.active
: # only delete in active VCol layer
294 for Data
in VColLayer
.data
:
295 Data
.keyframe_delete('color')
299 bpy
.ops
.object.editmode_toggle()
301 if Obj
.type == 'LATTICE':
302 if context
.window_manager
.key_shape
:
303 if Obj
.active_shape_key
:
304 for Point
in Obj
.active_shape_key
.data
:
305 Point
.keyframe_delete('co')
307 if Obj
.type == 'CURVE':
309 if context
.mode
!= 'OBJECT':
311 bpy
.ops
.object.editmode_toggle()
315 for Spline
in Data
.splines
:
316 if Spline
.type == 'BEZIER':
317 for CV
in Spline
.bezier_points
:
318 if context
.window_manager
.key_points
:
319 CV
.keyframe_delete('co')
320 CV
.keyframe_delete('handle_left')
321 CV
.keyframe_delete('handle_right')
322 if context
.window_manager
.key_radius
:
323 CV
.keyframe_delete('radius')
324 if context
.window_manager
.key_tilt
:
325 CV
.keyframe_delete('tilt')
327 elif Spline
.type == 'NURBS':
328 for CV
in Spline
.points
:
329 if context
.window_manager
.key_points
:
330 CV
.keyframe_delete('co')
331 if context
.window_manager
.key_radius
:
332 CV
.keyframe_delete('radius')
333 if context
.window_manager
.key_tilt
:
334 CV
.keyframe_delete('tilt')
337 bpy
.ops
.object.editmode_toggle()
343 class ANIM_OT_clear_animation_animall(bpy
.types
.Operator
):
344 bl_label
= 'Clear Animation'
345 bl_idname
= 'anim.clear_animation_animall'
346 bl_description
= 'Clear all animation'
347 bl_options
= {'REGISTER', 'UNDO'}
350 def invoke(self
, context
, event
):
352 wm
= context
.window_manager
353 return wm
.invoke_confirm(self
, event
)
356 def execute(op
, context
):
358 Data
= context
.active_object
.data
359 Data
.animation_data_clear()
365 bpy
.utils
.register_module(__name__
)
370 bpy
.utils
.unregister_module(__name__
)
374 if __name__
== "__main__":