Finding Final Frame and curve value at current frame

I’m writing a short python script to make an earthquake. It will put some random shaking on the X, Y or Z axis.

I’ve gotten it so it shakes on any axis over a chosen span of frames. But to make this more useful, I want it to be able to find out what the length of the timeline is so the user does not have to set it manually. I looked through the API library and didn’t find the answer.

Currently, the program just creates a keyframe on each frame within the assigned range. But I’d like to improve it so it adds the shaking to the current value at a given time on a given curve. Knowing the value at a given keyframe is easy, but I haven’t found out how to get the value of the curve at a given time. Does anyone know how to do this?


I am not 100% sure if this is what you need but

start = Blender.Get('staframe')
end  = Blender.Get('endframe')

might be what you need. Blender.Get() will give access to a host of other useful vars as well


I had looked at the Blender.Get function, but didn’t see any names for the first and last frames. I’ll try it out.

It worked Varkenvarken. Thanks.

And I figured out how to read the values of each curve at each frame. :smiley: