0
$\begingroup$

I have this python code that creates and object sets 2 keyframes and then sets the interpolation between them to constant however instead of doing his properly it seems move the objects smoothly to a different location and then move then instantly to the location I want them to be. Here's a simple example of what it roughly looks like:

import bpy
scn = bpy.context.scene

verts = [(0,0,0), (0,5,0), (0,5,5), (0,0,5)]
faces = [(0,1,2,3)]

examplemsh = bpy.data.meshes.new("example")
exampleobj = bpy.data.objects.new("example", examplemsh)
exampleobj.location = (0,0,0)
scn.objects.link(exampleobj)
examplemsh.from_pydata(verts,[],faces)
examplemsh.update(calc_edges = True)

exampleobj.keyframe_insert("location", frame=0, group="Location")
exampleobj.location = (5,5,5)
exampleobj.keyframe_insert("location", frame=5, group="Location")

kf = exampleobj.animation_data.action.fcurves[0].keyframe_points[0]
kf.interpolation = 'CONSTANT'

The constant interpolation seems to work but not after an very odd curving motion. Does ayone know what's going on?

$\endgroup$
3
  • $\begingroup$ There are 3 fcurves for location (x, y, z) You have only set constant interpolation for x fcurves[0]. Look in graph editor, x steps from 0 to 5 at frame 5. I believe what you want is constant extrapolation. See answer here ... or linear interpolation which will give a straight line between keyframepoints ? $\endgroup$
    – batFINGER
    Oct 10, 2017 at 14:35
  • $\begingroup$ @batFINGER My Laptop's run out of charge so I can't look too far into this but I assume I might be able to change 'interpolation' to 'extrapolation' $\endgroup$ Oct 10, 2017 at 14:45
  • 1
    $\begingroup$ Suggestion. Show your image from the Blender Graph Editor in your question. $\endgroup$ Oct 10, 2017 at 16:03

0

You must log in to answer this question.

Browse other questions tagged .