Im a bit confused.

I'm trying to get the weight from every vertex/point in a GreasePencil Stroke, to later assign them to another stroke in a different frame.

I can access the (active) GreasePencil by gpd = bpy.context.active_object, and its vertex groups by vg=gpd.vertex_groups.active According the API, I should get the weight by:


(I guess that the vertices are numerated from 0 to inf)

But when I call, lets say, vg.weight(0), I got:

RuntimeError: Error: Vertex not in group

NOTE: I'm calling that on a vertex group that has ALL its vertices/GreasePencilPoints fully painted red (weight=1.0), so as far as I know, every vertex should be in that vertex group.

I also tried:

for i in range(10000):
       print(i, vg.weight(i))

Just in case I was referencing an index that was not in the group, but I got nothing printed. But my vertex group is fully painted. So I'm lost.

Any idea how to access the weight?

Thank you so much.

Edit: I've found this answer but it doesn't seem to work (it creates a new vertex group, but the weights of each vertex/point are not modified), so I'm not sure if its buggy or how it is supposed to work.

Edit 2: Well, seems like adding vertex weight is not supported for GreasePencil

Any idea about getting the weight of a vertex/point?


1 Answer 1


Ok, so the methods for getting and setting the weight were actually in the GPencilStrokePoints collection:

import bpy
C = bpy.context

gpd = o.data

active_vertex_group =  o.vertex_groups.active
print("active Vertex group: ", active_vertex_group.name)
active_layer = gpd.layers.active
for frame in active_layer.frames:
    for stroke in frame.strokes:
        for i, p in enumerate(stroke.points):
            # Get
            point_weight = stroke.points.weight_get(vertex_group_index=active_vertex_group.index, point_index=i)
            print(i, point_weight)
            # Set
            stroke.points.weight_set(vertex_group_index=active_vertex_group.index, point_index=i, weight=.33)

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .