Page MenuHome

GPencil: Fix wrong python API for Point weights
ClosedPublic

Authored by Antonio Vazquez (antoniov) on Jan 22 2021, 7:01 PM.

Details

Summary

The old property never worked as expected because it was impossible expose the data as props.

Now, there are two methods to handle this: weight_get and weight_set

Example use:

import bpy
ob = bpy.context.active_object
gpd = ob.data
gps = gpd.layers[0].frames[0].strokes[0]
i = 0
print("Weights\n================================")
for pt in gps.points:
    gps.points.weight_set(vertex_group_index=0, point_index=i, weight=0.5)
    i +=1
    
i = 0    
for pt in gps.points:
    weight = gps.points.weight_get(vertex_group_index=0, point_index=i)
    print(weight)
    i +=1

Diff Detail

Repository
rB Blender
Branch
temp-gpencil-vertex-api
Build Status
Buildable 12555
Build 12555: arc lint + arc unit

Event Timeline

Antonio Vazquez (antoniov) requested review of this revision.Jan 22 2021, 7:01 PM
Antonio Vazquez (antoniov) created this revision.
source/blender/makesrna/intern/rna_gpencil.c
1317

The convention for the function name is rna_GPencilStrokePoints_weight_get.

1321

Please follow conventions for naming.

vertex_group_index for identifiers
Vertex Group Index for name
Vertex group index for descriptions (and preferably an actual description rather than repeating the name)

Rename functions after code review

Antonio Vazquez (antoniov) marked 2 inline comments as done.Feb 2 2021, 6:39 PM
This revision is now accepted and ready to land.Feb 6 2021, 4:33 PM