-2

update 2

the problem is very "easy"..bpy.ops.transform.transform(mode='TIME_TRANSLATE' DON'T WORK ...anything happend if you use that.... any action, any return, any error, any...

update 1

please check this video... I want to do the same with python but I don't know why this don't work

https://youtu.be/_h9WRh51d4A 1

-----------------

I'm trying with:

bpy.ops.transform.transform(mode='TIME_TRANSLATE', value=(0.996151, 0, 0, 0), axis=(0, 0, 0), constraint_axis=(False, False, False), constraint_orientation='GLOBAL', mirror=False, proportional='DISABLED', proportional_edit_falloff='SMOOTH', proportional_size=1)

but nothing happend.

if I use print that code return "finished" but if I use that in console that return {'CANCELLED'}

here my full code:

import bpy

numero_frames = 5

original_type = bpy.context.area.type
bpy.context.area.type = "DOPESHEET_EDITOR"


bpy.ops.action.select_leftright(
    mode='RIGHT', 
    extend=False)
bpy.ops.transform.transform(mode='TIME_TRANSLATE', value=(20, 0, 0, 0), axis=(0, 0, 0), proportional='DISABLED',  proportional_size=1, mirror=False, constraint_axis=(False, False, False), constraint_orientation='GLOBAL')


bpy.context.area.type = original_type

do you know what I'm doing wrong? I should be use another code?

yhoyo
  • 2,285
  • 13
  • 32
  • What exactly do you want to achieve? – p2or Jun 05 '15 at 12:02
  • 2
    Your attempt at overriding the context needs more work. I would expect better results from modify the fcurve data directly. bpy.context.active_object.animation_data.action.fcurves[0].keyframe_points[0].co[0] += 20 – sambler Jun 05 '15 at 12:35
  • @poor, I update with a fast video what I want – yhoyo Jun 05 '15 at 18:52
  • You need to explain what your problem is without resorting to a link to a video. Not everyone is willing to watch videos. – someonewithpc Jun 05 '15 at 20:49
  • @someonewithpc the problem is very "easy"..bpy.ops.transform.transform(mode='TIME_TRANSLATE' DON'T WORK ...anything happend if you use that.... any action, any return, any error, any!!...:( – yhoyo Jun 06 '15 at 01:48
  • 2
    @yhoyo If i am allowed to give you a tip about asking questions on BlenderStackExchange, it is this: First explain briefly what final effect you want (this explanation needs no code), then show some code you tried. – zeffii Jun 06 '15 at 09:26
  • I'd like to help, but unfortunately I don't understand the question to suggest alternatives. – p2or Jun 06 '15 at 13:01

1 Answers1

1

You want to translate, in time, the selected keyframes in the Dope Editor, via a script.

Run this in the Text Editor.

import bpy

for area in bpy.context.screen.areas:
    if area.type == 'DOPESHEET_EDITOR':
        ctx = bpy.context.copy()
        ctx['area'] = area # not actually needed...
        ctx['region'] = area.regions[-1] # ... just be nice

        bpy.ops.transform.transform(ctx,
            mode='TIME_TRANSLATE',
            value=(20, 0, 0, 0),
            axis=(0, 0, 0),
            proportional='DISABLED',
            constraint_orientation='GLOBAL')

        break

The downside is that a 'DOPESHEET_EDITOR' does need to be open.

Answer partially hoisted from: https://blender.stackexchange.com/a/8444/47

zeffii
  • 39,634
  • 9
  • 103
  • 186
  • thanks for answer but this don't work.... this still doing anything !!.. I'm thinking that may be is my blender's version (2.74)... I will change to new .2.75 tesbuilding in order to try ..... – yhoyo Jun 06 '15 at 15:10
  • 1
    the problem was the blende's version... all code work in the 2.75 testbuilding.... I don't know if I should report this "bug" ...??? – yhoyo Jun 06 '15 at 15:18
  • if it was fixed by updating to a new version then there is no good reason to submit a bug report. – zeffii Jun 06 '15 at 15:36