Page 1 of 1

vertex group related methods (blender 2.3)

Posted: Tue Nov 11, 2003 3:07 am
by jeoncity
Hello
I Want know about vertex group related method (blender 2.3)

Any help appriciated.

thanks.

Posted: Tue Nov 11, 2003 3:33 am
by ascotan
Heres the rundown:
This stuff will show up when the 2.3 blender python docs come out :)

addVertGroup(group):
Add a named and empty vertex (deform) group to the object this nmesh is
linked to. If this nmesh was newly created or accessed with GetRaw, it must first be linked to an object (with object.link or NMesh.PutRaw) so the method knows which object to update. This is because vertex groups in Blender are stored in the object -- not in the mesh, which may be linked to more than one object. For this reason, it's better to use "mesh = object.getData()" than "mesh = NMesh.GetRaw(meshName)" to access an existing mesh.
---------------------
removeVertGroup(group):
Remove a named vertex (deform) group from the object linked to this nmesh. All vertices assigned to the group will be removed (just from the group, not deleted from the mesh), if any. If this nmesh was newly created, it must first be linked to an object.
------------------------
assignVertsToGroup(group, vertList, weight, assignmode = 'replace'):
Adds an array (a python list) of vertex points to a named vertex group associated with a mesh. The vertex list is a list of vertex indices from the mesh. You should assign vertex points to groups only when the mesh has all its vertex points added to it and is already linked to an object.

Example:
The example here adds a new set of vertex indices to a sphere primitive::
import Blender
sphere = Blender.Object.Get('Sphere')
mesh = sphere.getData()
mesh.addVertGroup('firstGroup')
vertList = []
for x in range(300):
if x % 3 == 0:
vertList.append(x)
mesh.assignVertsToGroup('firstGroup', vertList, 0.5, 'add')
---------------------
removeVertsFromGroup(group, vertList = None):
Remove a list of vertices from the given group. If this nmesh was newly created, it must first be linked to an object.
-------------------
getVertsFromGroup(group, weightsFlag = 0, vertList = None):
Return a list of vertex indices associated with the passed group. This method can be used to test whether a vertex index is part of a group and if so, what its weight is.

Append this to the example from assignVertsToGroup:
# ...
print "Vertex indices from group %s :" % groupName
print mesh.getVertsFromGroup('firstGroup')
print "Again, with weights:"
print mesh.getVertsFromGroup('firstGroup',1)
print "Again, with weights and restricted to the given indices:"
print mesh.getVertsFromGroup('firstGroup',1,[1,2,3,4,5,6])

Posted: Fri Nov 14, 2003 9:16 pm
by jms
hi,

is there an easy method to rename a group?

Posted: Fri Nov 14, 2003 9:24 pm
by jms
jms wrote:hi,

is there an easy method to rename a group?
And is there also an easy method to know what are the names of all the vertsgroups in a given mesh?

Posted: Mon Nov 17, 2003 1:50 pm
by xand
your new addition causes a failure to compile.
'renameVertGroup' undeclared.

+++

Posted: Mon Nov 17, 2003 1:51 pm
by xand
your new addition causes a failure to compile.
'renameVertGroup' undeclared.

+++

Posted: Mon Nov 17, 2003 1:51 pm
by xand
your new addition causes a failure to compile.
'renameVertGroup' undeclared.

+++

Posted: Mon Nov 17, 2003 1:52 pm
by xand
your new addition causes a failure to compile.
'renameVertGroup' undeclared.

+++

Posted: Mon Nov 17, 2003 1:54 pm
by xand
your new addition causes a failure to compile.
'renameVertGroup' undeclared.

+++

Posted: Mon Nov 17, 2003 2:03 pm
by xand
your new addition causes a failure to compile.
'renameVertGroup' undeclared.

+++

Posted: Mon Nov 17, 2003 2:18 pm
by xand
your new addition causes a failure to compile.
'renameVertGroup' undeclared.

+++

Posted: Mon Nov 17, 2003 6:28 pm
by ascotan
There have been 2 more functions added to NMesh regarding vgroups. (not including the ones above) Nmesh.c was updated this morning but Nmesh.h was not updated with the function declarations. I have updated it so the source should compile.
p.s. You can submit this and other current cvs issues to the commiters or the python mailing list. :wink:

Posted: Tue Nov 18, 2003 1:32 pm
by xand
don't know why the message appears some many times.
the blender.org server have got a problem when i send the message. it says that the message wasn't send.

sorry for this.

Posted: Tue Nov 18, 2003 10:09 pm
by ascotan
rofl :P I thought you were pretty pissed or something. It was a good thing you said something though or else I might have forgotten.