I want to discover all vertices that are affected by a Shape Key.
I think this would involve comparing each vertex location for a key_blockkey_block
when its value is 0 and 1. However the following attempt doesn't produce any result:
import bpy, bmesh
shapeKeyName='Key 1'
o=bpy.context.object
#bpy.ops.object.mode_set(mode='EDIT')
m=bmesh.new()
m.from_mesh(o.data)
m.verts.ensure_lookup_table()
sk=bpy.context.object.data.shape_keys
for v in m.verts: #o.data.vertices:
bpy.context.object.data.shape_keys.key_blocks[shapeKeyName].value=0
co_basis = v.co
bpy.context.object.data.shape_keys.key_blocks[shapeKeyName].value=1
co_shape = v.co
if co_basis != co_shape:
print( shapeKeyName, 'affects vertex', v.index, co_basis, 'vs', co_shape )
I see at the end of the loop, key_blocks[shapeKeyName].valuekey_blocks[shapeKeyName].value
ends up at value 1 and the shape key is applied properly.