I'm generating a mesh from a list of locations and normals, for each vector a create a simple triangle. What I would like to do is to edit the weight of each triangle into a vertex group. I manage to do it in edit mode (painting) but when I get back to object mode, as its being generated procedurally, all weigths reset to 0.

I've checked some answers where they loop throught the weights but I want to stablish them. here is how it looks now:

enter image description here

It would be great also if I could choose between feed those weights from a list or paint the manually.


enter image description here


1 Answer 1


Animation Nodes doesn't have a node that can write vertex weights yet. So we will have to use some python to implement that ourselves. Given an object obj with a vertex group vertGroup and a float list weights containing the weights for each vertex, one can use this expression to set the vertex weights:

[obj.vertex_groups["vertGroup"].add([i], w, 'REPLACE') for i, w, in enumerate(weights)]

Node Tree

It is essential that the input object of the expression node be the output of the node used to set the mesh, this ensures the vertex weights to be set after the mesh is set.

Now, if you want to paint the weights by hand and have it preserved even when you are resetting the mesh each execution, you can do the following:

  1. Disable the Mesh Object Output node temporarily.
  2. Paint the weights.
  3. Cache the output of the Vertex Group Input node (caching is described in the documentation here)
  4. Enabled the Mesh Object Output node and use the cache in the node tree we described above.
  • $\begingroup$ I'm getting expression error, the output seems to be the problem, you specified that the expression output should be linked to a object Mesh Object Output which at the same time is the object of the input in the expression? check answer update image $\endgroup$ Oct 19, 2018 at 19:33
  • $\begingroup$ @JuanManuelLynch You got it backwards, I said the output of the Mesh Output should be the input of the expression. Remove that last node and let Animation Nodes type the output itself. $\endgroup$
    – Omar Emara
    Oct 19, 2018 at 19:42
  • $\begingroup$ ohhh, ok. I tried that already but i had the random number node badly configured, that's why I tried to put that object node at the end. Thanks $\endgroup$ Oct 19, 2018 at 19:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.