Getting vertex weights by vertex groups

To get the mesh vertex weights as they are distributed among its vertex groups with the Blender Python API, we need to correlate the vertex group indices with the group indices of the current vertex.

First, we need to loop through all the vertex groups of the mesh:

The index of the current group can be obtained through the “index” property

Define the list of vertices that are included in the vertex group with the current index:

Here, for each vertex of the current active object, we check whether the index of the current vertex group is included in the list of groups of this vertex.

As a result, we got lists of vertices for each vertex group:

One vertex can belong to several groups.

We can see which groups the vertex belongs to as follows:

To compare the vertex group indices with the index of each group of the vertex, we need to take the location of the desired vertex group index in vertex list of groups and get weights from this group:

As a result, we get a list of vertex weights according to the mesh’s vertex groups:

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comment
Inline Feedbacks
View all comments