Page MenuHome

grease pencil vertex group add fails in python
Closed, InvalidPublic

Description

System Information
Operating system and graphics card
Fedora, Intel Graphics

Blender Version
latest blender2.8 branch from git

Short description of error
the python below should add points to the new vertex group, but it fails.

Exact steps for others to reproduce the error
v = ob.vertex_groups.new(name="mygroup")
v.add( [1,2,3], weight=1.0, type="ADD")

Event Timeline

Bastien Montagne (mont29) lowered the priority of this task from 90 to 50.

I can confirm this, but it's not a bug but an unsupported python API feature.

The weight data in grease pencil reuse some areas of vertex groups used in meshes, but the weight point information is handle totally different due the nature of the internal strokes data and this is the reason the weight add is not working.

I will investigate how we can expose this api in python.

@Bastien Montagne (mont29) what we must do with this bug report? change status, close, I don't know?

@goat head (goathead) You could use a different approach.

After creating the vertex group, you can select the points of the stroke and then use the operator gpencil.vertex_group_assign.

I have not tested but I think it can be work.

Looking in detail in python API, the add function will never work because when adding a weight to vertex in a mesh, the vertex 1, 2, x is know, but in grease pencil, the vertex 1, 2, n is not like that, first you need define in what layer, in what frame and in what stroke are you adding the weight.

For example, the weight 1.0 to vertex 5 could be: Layer A->Frame 32->Stroke 75->Vertex 5 = 1.0

I need design an API to do that, but in any case, always will need a stroke parameter, never object only.

Antonio Vazquez (antoniov) changed the task status from Unknown Status to Unknown Status.Aug 11 2018, 5:07 PM

We can consider this as a non supported python api, so we can close the bug.

@goat head (goathead) You could use a different approach.

After creating the vertex group, you can select the points of the stroke and then use the operator gpencil.vertex_group_assign.

I have not tested but I think it can be work.

Anything that forces the python developers use bpy.ops because of limits in the API shouldn't be an option...
I was wondering if there is any update on this issue.