I have created the below script to simply retain the actual vertexes when editing a mesh rather than the encompassing method used by vertex groups.
(more detail about what it does after the code)
# WARNING very crude code, just a proof-of-concept at this point
import bpy
import Blender
from Blender.BGL import *
from Blender.Draw import *
from Blender import *
listv = []
# harcoded name for test purposes
sphere = Blender.Object.Get("Sphere")
sMesh = sphere.getData(False,True) # false for name only and true to get mesh data
def initSelection():
# clear listv
del listv[:]
for v in sMesh.verts:
if v.sel: listv.append(v.co)
# at this point the initialisation is complete, we have a copy of the coordinates of the unaltered vertex.
# now we wait until the user hits the select only original button
def SelectOnlyOriginal():
print "SelectOnlyOriginal():"
for v in sMesh.verts:
# if coords match entry in list select else deselect
v.sel=IsSelection(v.co)
def IsSelection(coord):
print "IsSelection",coord
returning=False
for co in listv:
if co==coord: returning=True
print "listv",co,"==",coord,returning
return(returning)
def draw():
global Button3, Button2, Button1
Button('Exit', 1, 106, 25, 39, 15, 'Exit script')
Button('init', 2, 58, 25, 39, 15, 'Initialise')
Button('SOO', 3, 0, 25, 49, 15, 'Select only original')
def event(evt, val):
if (evt== QKEY and not val): Exit()
def bevent(evt):
# must exit edit mode to continue
Window.EditMode(0)
if evt == 1: #Button1
Exit()
elif evt == 2: #Button2
initSelection()
elif evt == 3: #Button3
SelectOnlyOriginal()
# return to edit mode
Window.EditMode(1)
Register(draw, event, bevent)
Sometimes it works and the SOO button only selects the vertexes that I had recorded earlier but most of the time it selects nothing and I find all the saved vertex data is either random numbers or zero.
If it does work then clicking SOO again shows the listv variable is fubar.
What is affecting the listv variable ?
The reason for the script needs an example, create a Cube, select all the vertexes and add then to a vertex group, subdivide the mesh and select the original vertexes via the vertex group, oh, wait you can’t.
Now while I understand why that functionality would be useful it is not the functionality I want, hence the script.