Get vertex position with shape keys

Hi,
I’m trying to get a vertex position of an object that has shape keyframes. It seems that when I grab the vertex through python, I’m getting the ‘Basis’ shape, not the current position (as defined by the keyframe, and the current frame).
Anyone know how to do that?

Thanks,
Dave

I think I figured this out partly. The key nugget was that the vertex data lives in the shapekey data slot. (code below…)

Next problem: I’m running blender as follows:
blender file.blend -P script.py -f 193
script.py does something based on whatever the current keyframe is.
However, it seems that the when script.py is executed, not everything is fully loaded in the blend file (current frame isn’t set, for example). And all the ShapeKeys don’t have their values set right. Is there a way to get my script called after the blend file is completely loaded?

Thanks,
Dave
import bpy

scene = bpy.context.scene
xo = scene.objects[‘Water’]
xm = bpy.data.meshes[‘Water’]
bpy.context.scene.frame_current = 600

sk0 = xo.data.shape_keys.keys[‘Basis’]
sk1 = sk0

i = 0
for sk in xo.data.shape_keys.keys:
if sk.name != ‘Basis’ and sk.value > 0.0 :
sk1 = sk

i = 0
print (sk0.name, sk0.value)
print (sk1.name, sk1.value)
while i < len(sk0.data) :
dx = sk1.data[i].co[0] - sk0.data[i].co[0]
dy = sk1.data[i].co[1] - sk0.data[i].co[1]
dz = sk1.data[i].co[2] - sk0.data[i].co[2]

x = sk0.data[i].co[0] + sk1.value*dx
y = sk0.data[i].co[1] + sk1.value*dy
z = sk0.data[i].co[2] + sk1.value*dz
i = i+1
#print (i, (x,y,z))
print (i, (dx,dy,dz))

#print (sk.name, sk.value)