After installing the addon in the usual manner you get two new menu options: one in the Weights menu in Weight Paint mode called VertexColorsToWeights and a corresponding one in the Paint menu in Vertex Paint mode.
Weight paint mode
In weight paint mode clicking onWeights -> VertexColorToWeight
will transfer a color from the active vertex color layer to the active vertex group. If there is no vertex color layer present a will cretae a new one. You have an option to choose which color channel to use as weight or to combine all colors. Vertex paint mode
In vertex paint mode clicking onPaint -> WeightToVertexColor
will transfer the weights from the active vertex group to the active vertex color layer. if there is no veretx group present it will create a new one. You have again an option to transfer the weights to a single color channel or to all color channels.
Thank you, Michel! I just tried your .py, but I get
ReplyDeleteline 178, in execute
ValueError: bpy_struct: item.attr = val: sequences of dimension 0 should contain 4 items, not 3
Could that be a Python version mismatch?
I'm using recent Blender Foundation versions of Blender 2.79,
which come with Python 3.7.
Python mismatch, indeed: I just tried it with the official
ReplyDeleteBlender 2.79b, which comes with Python 3.5, and it works like a charm.
How time-consuming would it be for you to update it to Python 3.7
(which is also what recent builds of Blender 2.80 use)?
I am sorry but my time is too limited to actively provide support for the free add-ons on non-official Blender version. I agree it would be sensible to make stuff compatible with Python 3.7, but 2.8 is beta and even worse, the Python API is not stable at this point so it would be a waste of time in my opinion to try and shoot at a moving target.
DeleteHaving said that, that doesn't mean I am averse to keeping the free stuff up to date: if someone sends me a pull request with a patch I am certainly willing to consider it for a merge, it is just that my own time is a bit limited :-(
Understood. But I feel enough motivation to attempt a hack.
DeleteOn a simple .blend, your .py with Blender 2.79b works;
not so with a more complex .blend,
and the error hails from line 176 or 178,
inside an iteration on mesh.loops,
which makes me wonder:
why not iterate over the mesh’s vertices?
Aha: In Blender 2.79b,
ReplyDeletebpy.context.active_object.data.vertex_colors.active[0].color
has three components; in recent Blender 2.79 builds, it has four!