vertex group related methods (blender 2.3)

Scripting in Blender with Python, and working on the API

Moderators: jesterKing, stiv

Post Reply
jeoncity
Posts: 0
Joined: Mon Nov 10, 2003 4:30 am

vertex group related methods (blender 2.3)

Post by jeoncity »

Hello
I Want know about vertex group related method (blender 2.3)

Any help appriciated.

thanks.

ascotan
Posts: 0
Joined: Thu May 29, 2003 10:32 pm
Location: Maryland, U.S.

Post 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])

jms
Posts: 33
Joined: Sat Oct 19, 2002 3:04 pm

Post by jms »

hi,

is there an easy method to rename a group?
Zoo-3D.Blender, Ze French-Speaking Community SKB My french book about Blender.

jms
Posts: 33
Joined: Sat Oct 19, 2002 3:04 pm

Post 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?
Zoo-3D.Blender, Ze French-Speaking Community SKB My french book about Blender.

xand
Posts: 33
Joined: Wed Oct 16, 2002 9:46 am

Post by xand »

your new addition causes a failure to compile.
'renameVertGroup' undeclared.

+++

xand
Posts: 33
Joined: Wed Oct 16, 2002 9:46 am

Post by xand »

your new addition causes a failure to compile.
'renameVertGroup' undeclared.

+++

xand
Posts: 33
Joined: Wed Oct 16, 2002 9:46 am

Post by xand »

your new addition causes a failure to compile.
'renameVertGroup' undeclared.

+++

xand
Posts: 33
Joined: Wed Oct 16, 2002 9:46 am

Post by xand »

your new addition causes a failure to compile.
'renameVertGroup' undeclared.

+++

xand
Posts: 33
Joined: Wed Oct 16, 2002 9:46 am

Post by xand »

your new addition causes a failure to compile.
'renameVertGroup' undeclared.

+++

xand
Posts: 33
Joined: Wed Oct 16, 2002 9:46 am

Post by xand »

your new addition causes a failure to compile.
'renameVertGroup' undeclared.

+++

xand
Posts: 33
Joined: Wed Oct 16, 2002 9:46 am

Post by xand »

your new addition causes a failure to compile.
'renameVertGroup' undeclared.

+++

ascotan
Posts: 0
Joined: Thu May 29, 2003 10:32 pm
Location: Maryland, U.S.

Post 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:

xand
Posts: 33
Joined: Wed Oct 16, 2002 9:46 am

Post 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.

ascotan
Posts: 0
Joined: Thu May 29, 2003 10:32 pm
Location: Maryland, U.S.

Post 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.

Post Reply