Revision: 36859 http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=36859 Author: aligorith Date: 2011-05-24 11:15:21 +0000 (Tue, 24 May 2011) Log Message: ----------- == Animated Transforms to Deltas ==
Added operator to convert animation for standard object transforms (i.e. loc/rot/scale) to delta transforms. This can be accessed from the Object -> Transform -> Animated Transforms To Deltas menu entry in the 3D View. Since the situation which causes this is quite common (especially for motion-graphics type applications), where users animate some object first and then decide to duplicate this and place it around the place in different locations, it's probably important that we have some support for this kind of thing. Newbies with the "help, all my anmated duplicates disappear" problem are recommended to use this operator from hereon in. For reference of rationale, see: http://blenderartists.org/forum/showthread.php?219126-Move-Existing-f -Curve-to-delta-equivalent Modified Paths: -------------- branches/soc-2011-pepper/release/scripts/startup/bl_operators/object.py branches/soc-2011-pepper/release/scripts/startup/bl_ui/space_view3d.py Modified: branches/soc-2011-pepper/release/scripts/startup/bl_operators/object.py =================================================================== --- branches/soc-2011-pepper/release/scripts/startup/bl_operators/object.py 2011-05-24 11:01:39 UTC (rev 36858) +++ branches/soc-2011-pepper/release/scripts/startup/bl_operators/object.py 2011-05-24 11:15:21 UTC (rev 36859) @@ -564,3 +564,44 @@ for obj in context.scene.objects: obj.hide_render = False return {'FINISHED'} + +class TransformsToDeltasAnim(bpy.types.Operator): + '''Convert object animation for normal transforms to delta transforms''' + bl_idname = "object.anim_transforms_to_deltas" + bl_label = "Animated Transforms to Deltas" + bl_options = {'REGISTER', 'UNDO'} + + @classmethod + def poll(cls, context): + obs = context.selected_editable_objects + return (obs is not None) + + def execute(self, context): + for obj in context.selected_editable_objects: + # get animation data + adt = obj.animation_data + if (adt is None) or (adt.action is None): + self.report({'WARNING'}, "No animation data to convert on object: " + obj.name) + continue + + # if F-Curve uses standard transform path, just append "delta_" to this path + for fcu in adt.action.fcurves: + if fcu.data_path == "location": + fcu.data_path = "delta_location" + obj.location.zero() + elif fcu.data_path == "rotation_euler": + fcu.data_path = "delta_rotation_euler" + obj.rotation_euler.zero() + elif fcu.data_path == "rotation_quaternion": + fcu.data_path = "delta_rotation_quaternion" + obj.rotation_quaternion.identity() + #elif fcu.data_path == "rotation_axis_angle": # XXX: currently not implemented + # fcu.data_path = "delta_rotation_axis_angle" + elif fcu.data_path == "scale": + fcu.data_path = "delta_scale" + obj.scale = (1, 1, 1) + + # hack: force animsys flush by changing frame, so that deltas get run + context.scene.frame_set(context.scene.frame_current) + + return {'FINISHED'} Modified: branches/soc-2011-pepper/release/scripts/startup/bl_ui/space_view3d.py =================================================================== --- branches/soc-2011-pepper/release/scripts/startup/bl_ui/space_view3d.py 2011-05-24 11:01:39 UTC (rev 36858) +++ branches/soc-2011-pepper/release/scripts/startup/bl_ui/space_view3d.py 2011-05-24 11:15:21 UTC (rev 36859) @@ -181,6 +181,10 @@ layout.operator("object.randomize_transform") layout.operator("object.align") + + layout.separator() + + layout.operator("object.anim_transforms_to_deltas") class VIEW3D_MT_mirror(bpy.types.Menu): _______________________________________________ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org http://lists.blender.org/mailman/listinfo/bf-blender-cvs