# Getting vertex weights with the vertex proximity modifier

I am trying to use the Vertex Proximity Modifier to update vertex weights and hoping to be able to read the same with Python.

I have a plane and a vertex group called "all" (which includes all the vertices and default weight 0.0) and the proximity object is set to a sphere. The modifier behaves as expected. But when I try the following code:

import bpy

obj = bpy.context.active_object # select the plane

for i in range(0, 24): # I know there are 25 vertices
print (obj.vertex_groups['all'].weight(i))


I get 0.0 printed out for each vertex. Can I get the individual weight of each vertex with the modifier in action but not applied? (If I apply the modifier, then I get the intended results.)

# Use bpy.types.Object.to_mesh:

to_mesh(scene, apply_modifiers, settings, calc_tessface=True, calc_undeformed=False)


Create a Mesh datablock with modifiers applied

import bpy