1
$\begingroup$

Please forgive poor English by translation

Version used: 3.0.0 Alpha

I tried to get (every frame) the Weight with the following script, but it didn't work I tried to get the Weight by using the following script, but I could not get the Weight change by Dynamic Paint.

### Python Code
import bpy
meshName: str = 'Cube'

# vars
obj = bpy.data.objects[meshName]

def handler(Scene): 

    # count vertices
    weight = [0]*len(obj.data.vertices)

    # get and assign weight 
    for i in range(len(obj.data.vertices)):
        try: weight[i] = obj.vertex_groups[0].weight(i)
        except: pass
    print(weight)
    
bpy.app.handlers.frame_change_pre.append(handler) 

The weight obtained by vertex_groups can only be obtained before Dynamic Paint is applied. Also, I could not get the value by duplicating the vertex group in the modifier and referencing it.

How can I fix this?

$\endgroup$

1 Answer 1

0
$\begingroup$

I solved the problem myself.

I used the following as a reference. Thanks!

https://blender.stackexchange.com/a/166390/134117

### Python Code
import bpy

meshName: str = 'Cube'

# vars
obj = bpy.data.objects[meshName]
depsgraph = bpy.context.eva luated_depsgraph_get()
object_eval = obj.evaluated_get(depsgraph)

def handler(Scene): 

    # count vertices
    weight = [0]*len(object_eval.data.vertices)

    # get and assign weight 
    for i in range(len(object_eval.data.vertices)):
        try: weight[i] = object_eval.vertex_groups[0].weight(i)
        except: pass
    print(weight)
    
bpy.app.handlers.frame_change_pre.append(handler) 
$\endgroup$

You must log in to answer this question.

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