Get vertex position with shape keys

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?


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 -f 193 does something based on whatever the current keyframe is.
However, it seems that the when 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?

import bpy

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

sk0 =[‘Basis’]
sk1 = sk0

i = 0
for sk in
if != ‘Basis’ and sk.value > 0.0 :
sk1 = sk

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

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

#print (, sk.value)