Newbie at Python need help


I’m working on an animation in which one I make an object to go through a tube. As it reaches the end of the tube, I would like it to start again from the beginning of the tube (like a html marquee) while the entire animation still running. As I couldn’t do it with the generic blender tools (or tell me if I can), I managed to do it with a python script as follow:

import Blender

donnee = Blender.Object.Get(‘myObjectName’)
Blender.Set(‘curframe’, 1)
donnee.setLocation(0.0, 0.0, 0.0)
originY = donnee.LocY

#want to move along Y coord

for i in range(1, 50):
Blender.Set(‘curframe’, i)
donnee.setLocation(0.0, i, 0.0)

    #simulate marquee, reinitialize position and start again
    if(donnee.LocY > 30):
             donnee.setLocation(0.0, 0.0, 0.0)

With this code, I can see myObject moving as I expect, but of course, location at each frame is not saved. I guess, I have to insert keyframes at concerned frames but I don’t know how.

Anyone could help please ?

you can make objects go back to the begining of the tube using only an ipo

simply keyframe the begining and end, then select your curves in the IPO window [probably all of them using the A key], and press Cuve->Extend Mode->Cyclic

that’s peculiar, couldn’t you rotate some handle types in older versions of blender? [guess not, only in edit mode of curves in the 3d view]

thank you,

that was the thing I was looking for.


This link will send you to the Sequence Editor tutorial in the Blender docs. The Third Animation: a tunnel section gives you a detailed description in how to do what you want to do. Hope this helps a bit.