forked from bartvdbraak/blender
== 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
This commit is contained in:
parent
3ccbfef6be
commit
a5b07c0934
@ -564,3 +564,44 @@ class ClearAllRestrictRender(bpy.types.Operator):
|
||||
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'}
|
||||
|
@ -181,6 +181,10 @@ class VIEW3D_MT_transform(bpy.types.Menu):
|
||||
|
||||
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):
|
||||
|
Loading…
Reference in New Issue
Block a user