I need to update a 2.49 blender code to 2.74 but I can't find in Blender 2.74 a module named Ipo. Someone can help me? Below, part of my code in 2.49 version.

  obj = Object.Get('obj'+str(visNames.index(ni)))    

  ipo = Ipo.New('Object','obj'+str(visNames.index(ni))+'.ipo')

  curveTime = ipo.addCurve('Time')

  curveLocX = ipo.addCurve('LocX')

  curveLocY = ipo.addCurve('LocY')

  curveLocZ = ipo.addCurve('LocZ')

From 2.50 Ipo's have been replaced with Actions. While you can create an action with bpy.ops.action.new() you can also just add a keyframe to a property and the action will be created for you. Instead of Ipo curves we now use f-curves.

Starting with getting an object by name

obj = bpy.data.objects['Cube']

You can then use keyframe_insert to key all 3 axes of the objects location with


To key just one axis you can specify an index (X=0 Y=1 Z=2)

obj.keyframe_insert('location', index=0)

You could add multiple keyframes from a list

x = [1.0, 2.0, 3.0]
xframes = [0, 10, 20]
for i in range(len(x)):
    obj.location.x = x[i]
    obj.keyframe_insert('location', index=0, frame=xframes[i])

For the interpolation, each keyframe has it's own interpolation setting. A simple loop can set each keyframe to use the same interpolation.

objCurves = obj.animation_data.action.fcurves
for curve in objCurves:
    # here you can also test curve.array_index to find
    # the curve of a specific axis
    # array_index matches the index used in keyframe_insert
    if curve.data_path == 'location':
        for k in curve.keyframe_points:
            k.interpolation = 'LINEAR'

From blender v2.76 you can use objCurves.find() to get the specific curve that you want.

objCurves = obj.animation_data.action.fcurves
for i in [0,1,2]:
    curve = objCurves.find('location', index=i)
    for k in curve.keyframe_points:
        k.interpolation = 'LINEAR'
  • $\begingroup$ Thanks @sambler, this explanation was very useful for me. But, there is an error in curve = objCurves.find('location', index=i) that appear the following message: find() takes no keywords arguments . I didn't understand this. Finally, in 2.49 Ipo's version I have: for i in range(len(x)): curveLocX.addBezier((xtime[i],x[i])) Can I add Bezier using keyframe_insert after that linear interpolation that you showed for me? $\endgroup$ – Jimmy Jan 19 '16 at 20:13
  • $\begingroup$ My bad fcurve.find() was added in 2.76. You have one fcurve for each property, it contains a point for each keyframed value. You use multiple keyframe_insert with different frames to animate the value. $\endgroup$ – sambler Jan 20 '16 at 6:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.