IPO help (for stiring simulator)


I’m in the process of writing a string simulator for Blender here. I’m prototyping in Python. I have never dealt with IPO’s through Python before (and my Python is a little rusty too)

All I want to do is set keyframes for an object from the simulator. I would like the set the LocX, LocY and LocZ values then set the keyframe. I’ve looked in the API and on elysiun but I can’t seem to get it working.

The reason is I can no longer just keep pressing Alt + P to see what is happening as I need to store values from the first frame :wink: .

Say my object is called “Sphere”. Could anyone be kind enough to give a quick code snippet how to do this?

just check any of the BlODEd scripts since i have a makeipo function aswell as a bakeipo function in all the scripts i released for it that do as it says, makes an ipo and then bakes the current rot and loc into it.

def makeipo(name):
    ipo = Ipo.New('Object', name)
    Locx = ipo.addCurve('LocX')
    Locy = ipo.addCurve('LocY')
    Locz = ipo.addCurve('LocZ')
    Rotx = ipo.addCurve('RotX')
    Roty = ipo.addCurve('RotY')
    Rotz = ipo.addCurve('RotZ')
    for c in [Locx,Locy,Locz,Rotx,Roty,Rotz]:
    return ipo
def bakeipo(ipo, frame, obj):
    Locx = ipo.getCurve('LocX')
    Locy = ipo.getCurve('LocY')
    Locz = ipo.getCurve('LocZ')
    Rotx = ipo.getCurve('RotX')
    Roty = ipo.getCurve('RotY')
    Rotz = ipo.getCurve('RotZ')


now your rotation bake probably won’t have the *5729 since thats to deal with radian conversion but i’m sure you can figure something out.



Thanks for the reply.

I just can’t get it to work. Firstly, where is addCurve in the API documentation? I can’t see it. The error I get is:

ValueError: Not a valid param

Here is the exact code I am using on 2.33 (the cvs version after it was frozen):

import Blender
from Blender import*

def makeipo(name):

ipo = Ipo.New(‘Object’, name)

Locx = ipo.addCurve(“LocX”)
Locy = ipo.addCurve(“LocY”)
Locz = ipo.addCurve(“LocZ”)

for c in [Locx,Locy,Locz]:

return ipo

def bakeipo(ipo, frame, obj):

Locx = ipo.getCurve('LocX')
Locy = ipo.getCurve('LocY')
Locz = ipo.getCurve('LocZ')



What am I doing wrong?


Here’s the code I used to create IPOs and set keyframe from BlenderPeople (in this sample code, Actor is a Blender object):

Actor.clearIpo() #unlink existing Ipo

actorIpo = Blender.Ipo.New('Object','actorIpo') #create new Ipo object

Actor.setIpo(actorIpo) #assign it to the Actor object

actorIpoX=actorIpo.addCurve('LocX') #add translate curves

actorIpoRZ=actorIpo.addCurve('RotZ') #add a curve for z rotation

thisFrame=Blender.Get('curframe') #get the current frame




Notes on this code:

  • the list actorLocation holds the current position [x,y,z] of the object in this case, but it could be they would be any float values you wanted, really
  • the calculation in the Z rotation Ipo assignment is converting from what a rotation query on the object would get you and the format (dekadegrees?) that rotation Ipos are stored in.


Your code snippet works and I can easily adapt it. It looks almost identical to what I was trying - no idea what I was doing wrong. Anyway…


[Edit] Just realised I was looking at outdated API documentation (idiot!)

Ok, I am getting the same error message:
ValueError: not a valid param

This is the code:

      tempIpo = Ipo.New('Object', 'ipo.'+`b`)     # construct the ipo: Type: Object, Name: ipo.NNN

      Locx = tempIpo.addCurve('LocX')          # add the skeleton curves X,Y,Z
      Locy = tempIpo.addCurve('LocY')
      Locz = tempIpo.addCurve('LocZ')

The problem is with the “Locx = tempIpo.addCurve(‘LocX’)”
I am using Blender 2.34, and was looking at the docs for version 2.34 and I can’t seem to figure it out.

Please help! I only have a few hairs left! haha.


OK, is there any way to add an ipo curve to an ipo
without using ipo.addCurve?

I am still getting a “ValueError: not a valid param” error
when I run:

temp = Ipo.New("Object", aName )

locx = temp.addCurve("LocX")

is this a bug? Can anyone else reproduce the error?
Please help!!!

That problem was addressed in teh Python mailign list and fixed int eh CVS version

the problem was that you needed to link the ipo to the object before you could give it curves, they remvoed that bit cause it was causign too much problems.


Ah! Thanks, at least now I know I am not going insane,
(as much) or that my computer decided an int is 27.5

So, that means in the next version (2.35 I assume) the above
code will work, and in the meantime, I need to add the ipo to
the object, THEN give it curves? Correct?

Thanks again,

yeah, code is

obj = Blender.Object.Get(aName)
temp = Ipo.New("Object", aName ) 
locx = temp.addCurve("LocX") 


Thanks much!

I was getting worried I was going to
have to wait until the next release!