
# this script interpolates vertex weight values 
# between min and max objects


import Blender

sphere = Blender.Object.Get('Plane')
max = Blender.Object.Get('max')
min = Blender.Object.Get('min')
mesh = sphere.getData()
vertList = []
alist = []
group = 'gg'
groups = []
pos = 1

groups = mesh.getVertGroupNames()
vertList = mesh.getVertsFromGroup(group)
for x in vertList:
    y = mesh.verts[x].co[1]
    ymin = min.getLocation()[1]
    ymax = max.getLocation()[1]
    if ymax-ymin <> 0:
        weight = (y - ymin)/(ymax -ymin)
 

    if y > ymin and y < ymax:
        alist.append(x)
        mesh.assignVertsToGroup(group, alist, weight, 'replace')
        alist = []
    
    if y > ymax:
        alist.append(x)
        mesh.assignVertsToGroup(group, alist	, 1.0, 'replace')
        alist = []

    if y < ymin:
        alist.append(x)
        mesh.assignVertsToGroup(group, alist	, 0.0, 'replace')
        alist = []

mesh.update()

