object and vertex group

is there a way to find vertices inside a vertex group in an object and how
with al little script


Assuming you know the name of the vertex group, and want the indices of the vertexes in the group (and assuming its a mesh object, which you may want to check):

import Blender
from Blender import Object
ob = Object.Get("MyObject")
me = ob.getData(mesh = True)
vgIndex = me.getVertsFromGroup("The Group I Want")

You can then iterate through vgIndex to do stuff like location, etc.

but what happen if you don’t know the name of the vertex group?

you may know the object name and that there is one vertex group wiht a certain qty of vertices and want to get the location of theses vertices

anyway to get this info ?


You sure can:

import Blender
from Blender import Object
ob = Object.Get("MyObject")
me = ob.getData(mesh = True)
verts = None
theLengthIWant = 1 # your number
for name in me.getVertGroupNames():
     verts = me.getVertsFromGroup(name)
     if len(verts) == theLengthIWant:
          verts = None
if verts == None:
     print 'No vertex group with %d vertexes found', %(theLengthIWant)
     # You can continue on...

for the first part in

vgIndex = me.getVertsFromGroup(“The Group I Want”)

this means that you already have the VG name then
how do you go through the list of vertex

i mean Vgindex would contain the list of vertices inside the Vextex group only
or also all the edges and faces associated with it ?


Just looking along these lines myself:

ob = Blender.Object.Get(mesh_name.val)
if str(ob.type)=='Mesh':
    mesh = ob.getData()    
    if hasattr(mesh,'getVertGroupNames'):
        mesh_groups = mesh.getVertGroupNames()
        vv = mesh.getVertsFromGroup(mesh_groups[mesh_group_sel.val])

My question is, how do you update the vector elements?

mesh.verts[0].co[0] = numx.val

Just iterate through the verts member of the mesh:

for vId in vgIndex:
    vert = me.verts[vId]
    # Continue your processing

It just contains the list of vertex indices. If you want the edges or faces it will require additional processing. There was a thread not too long ago that had how to find the faces in it, and edges are not much different (they’re probably easier).

Just wondering about the object portion of this question.

How can I find out what group an object belongs to? (Not Vertex)

that type of group has nothing to do with object group!

so may be better start a new thread on this subject !