fix [#36995] FBX Importer does not import fbx model
[blender-addons.git] / animation_animall.py
blobc331f5249eb4fd1ec3c85cfb05615db44f9c8fde
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 #####
19 bl_info = {
20 'name': 'AnimAll',
21 'author': 'Daniel Salazar <zanqdo@gmail.com>',
22 'version': (0, 5),
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)',
26 'warning': '',
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 -------------------------------------------------------------------------"""
45 import bpy
46 from bpy.props import *
50 # Property Definitions
52 bpy.types.WindowManager.key_shape = BoolProperty(
53 name="Shape",
54 description="Insert keyframes on active Shape Key layer",
55 default=True)
57 bpy.types.WindowManager.key_uvs = BoolProperty(
58 name="UVs",
59 description="Insert keyframes on active UV coordinates",
60 default=False)
62 bpy.types.WindowManager.key_vcols = BoolProperty(
63 name="VCols",
64 description="Insert keyframes on active Vertex Color values",
65 default=False)
67 bpy.types.WindowManager.key_vgroups = BoolProperty(
68 name="VGroups",
69 description="Insert keyframes on active Vertex Group values",
70 default=False)
72 bpy.types.WindowManager.key_points = BoolProperty(
73 name="Points",
74 description="Insert keyframes on point locations",
75 default=True)
77 bpy.types.WindowManager.key_radius = BoolProperty(
78 name="Radius",
79 description="Insert keyframes on point radius (Shrink/Fatten)",
80 default=False)
82 bpy.types.WindowManager.key_tilt = BoolProperty(
83 name="Tilt",
84 description="Insert keyframes on point tilt",
85 default=False)
88 # GUI (Panel)
90 class VIEW3D_PT_animall(bpy.types.Panel):
92 bl_space_type = 'VIEW_3D'
93 bl_region_type = 'TOOLS'
94 bl_label = 'AnimAll'
95 bl_options = {'DEFAULT_CLOSED'}
96 # show this addon only in the Camera-Data-Panel
97 @classmethod
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'
104 # draw the gui
105 def draw(self, context):
107 Obj = context.active_object
109 layout = self.layout
110 col = layout.column(align=True)
111 row = col.row()
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")
119 row = col.row()
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")
126 row = col.row()
127 row.prop(context.window_manager, "key_tilt")
129 row = col.row()
130 row.operator('anim.insert_keyframe_animall', icon='KEY_HLT')
131 row.operator('anim.delete_keyframe_animall', icon='KEY_DEHLT')
132 row = layout.row()
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()
140 row = split.row()
142 if ShapeKey:
143 row.label(ShapeKey.name, icon='SHAPEKEY_DATA')
144 row.prop(ShapeKey, "value", text="")
145 row.prop(Obj, "show_only_shape_key", text="")
146 else:
147 row.label('No active ShapeKey', icon='INFO')
150 class ANIM_OT_insert_keyframe_animall(bpy.types.Operator):
151 bl_label = 'Insert'
152 bl_idname = 'anim.insert_keyframe_animall'
153 bl_description = 'Insert a Keyframe'
154 bl_options = {'REGISTER', 'UNDO'}
157 # on mouse up:
158 def invoke(self, context, event):
160 self.execute(context)
162 return {'FINISHED'}
165 def execute(op, context):
167 Obj = context.active_object
169 if Obj.type == 'MESH':
170 Mode = False
171 if context.mode == 'EDIT_MESH':
172 Mode = not Mode
173 bpy.ops.object.editmode_toggle()
175 Data = Obj.data
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')
197 if Mode:
198 bpy.ops.object.editmode_toggle()
200 if Obj.type == 'LATTICE':
201 Mode = False
202 if context.mode != 'OBJECT':
203 Mode = not Mode
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')
211 if Mode:
212 bpy.ops.object.editmode_toggle()
214 if Obj.type == 'CURVE':
215 Mode = False
216 if context.mode != 'OBJECT':
217 Mode = not Mode
218 bpy.ops.object.editmode_toggle()
220 Data = Obj.data
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')
243 if Mode:
244 bpy.ops.object.editmode_toggle()
247 return {'FINISHED'}
250 class ANIM_OT_delete_keyframe_animall(bpy.types.Operator):
251 bl_label = 'Delete'
252 bl_idname = 'anim.delete_keyframe_animall'
253 bl_description = 'Delete a Keyframe'
254 bl_options = {'REGISTER', 'UNDO'}
257 # on mouse up:
258 def invoke(self, context, event):
260 self.execute(context)
262 return {'FINISHED'}
265 def execute(op, context):
267 Obj = context.active_object
269 if Obj.type == 'MESH':
270 Mode = False
271 if context.mode == 'EDIT_MESH':
272 Mode = not Mode
273 bpy.ops.object.editmode_toggle()
275 Data = Obj.data
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')
298 if Mode:
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':
308 Mode = False
309 if context.mode != 'OBJECT':
310 Mode = not Mode
311 bpy.ops.object.editmode_toggle()
313 Data = Obj.data
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')
336 if Mode:
337 bpy.ops.object.editmode_toggle()
340 return {'FINISHED'}
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'}
349 # on mouse up:
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()
361 return {'FINISHED'}
364 def register():
365 bpy.utils.register_module(__name__)
367 pass
369 def unregister():
370 bpy.utils.unregister_module(__name__)
372 pass
374 if __name__ == "__main__":
375 register()