-2
$\begingroup$

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?

$\endgroup$
7
  • $\begingroup$ What exactly do you want to achieve? $\endgroup$
    – p2or
    Commented Jun 5, 2015 at 12:02
  • 2
    $\begingroup$ 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 $\endgroup$
    – sambler
    Commented Jun 5, 2015 at 12:35
  • $\begingroup$ @poor, I update with a fast video what I want $\endgroup$
    – yhoyo
    Commented Jun 5, 2015 at 18:52
  • $\begingroup$ You need to explain what your problem is without resorting to a link to a video. Not everyone is willing to watch videos. $\endgroup$ Commented Jun 5, 2015 at 20:49
  • 2
    $\begingroup$ @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. $\endgroup$
    – zeffii
    Commented Jun 6, 2015 at 9:26

1 Answer 1

1
$\begingroup$

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

$\endgroup$
3
  • $\begingroup$ 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 ..... $\endgroup$
    – yhoyo
    Commented Jun 6, 2015 at 15:10
  • 1
    $\begingroup$ 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" ...??? $\endgroup$
    – yhoyo
    Commented Jun 6, 2015 at 15:18
  • $\begingroup$ if it was fixed by updating to a new version then there is no good reason to submit a bug report. $\endgroup$
    – zeffii
    Commented Jun 6, 2015 at 15:36

Not the answer you're looking for? Browse other questions tagged .