Shapekey Values not acting the same in console vs. running a script

Can someone help me debug this? (or let me know that yes, I have found a bug)

In the console if I ask for a shape key’s value, it gives me the correct value based on which frame I’m on, but if I do the same thing in a while loop seeking through the frames, it always returns the same value. Weird. For instance:

In the console:

>>> Eyes =['Plane'].data.shape_keys.key_blocks['eyes']
>>> Eyes.value
>>> bpy.ops.anim.change_frame(frame=5)
>>> Eyes.value

That works, but if I write:

while i < LastFrame:

This just spits out a sequence of repeating, equal, values.

(Also as usual, am I just working wrong? What I really want is to be able to select all the shape key values, query max and min, then scale to normalize, but, y’know, Documentation…

I think this comes under

You could throw in a scene.update(), or if your key values are only keyed query the fcurve directly.

for i in range(StartFrame, LastFrame):

Seeing as you are looking at a frame change you could also put it in a frame change handler

import bpy

def frame_change(scene):
    # run some scripts if the cube has moved.
    Eyes = scene.objects["Plane"].data.shape_keys.key_blocks["eyes"]

OHHHHH. It’s one of those “don’t bog down the machine horribly” things.

Of course, I kind of knew I wasn’t making the best decision when I started using this method of finding max and min of an FCurve…