change material of vertexGroup

Hi,

as written in the title, i have a problem changing the material of a vertexGroup using Python.

So i have an object with different vertexGroups. And now i would like to change the color of a specific vertexGroup. How can i do this???

I really read the docu, but i can’t find anything. How can i access vertexGroups? Changing the color, i thought the easiest way to do this, is to define a different material and switch to this. Am i right? But how?

please help me!!!

Greetings,

can anybody help?

I’d assume in edit mode you select only the verts in that group then assign the material. Have you tried that?

no i dont think a material is related to the color of the vertex. So changing the material wont help you. It must be a seperate parameter. Vertex group are in bpy.context.scene.object[name of the object].vertex_groups[number of vertex group or name]

but i dont see any color parameter in there

The thread title and OP specify a material!

The thread title and the post specify NOTHING since there is a clear confusion between material and vertex color. Two diffirent thing that are completely unrelated.

there is no materials for vertex_groups.

Also even though the title says about materials, he then ask for vertex colors. By the way , vertex color is unrelated to diffuse and specular color and in no way related to the material data structure beyond use_color_paint and use_vertex_color_light , which are Boolean types and in no way affecting or editing vertex_color.

Assigning a material to an object’s vertices , is a simple procedure, you select the object, go to edit mode, selected the vertices and call bpy.ops.material.new() and then bpy.ops.object.material_slot.assign() to create and assign the material slot and the corresponding material to the selected object’s vertices. BUT !!! THIS IS NOT vertex color editing or creation for a vertex_group color .

Hi,

thanks for your help. I’m quite new to Blender so it’s possible that i don’t distinguish everything correctly. In the attachment there’s a blend-file where i have a sphere with 1 vertex-group. this group has a different material than the rest of the sphere. Thus a different color.
That’s what i want to do, but using python.

I check out your ideas and write later again! Thanks so far.

twoMaterials.blend (387 KB)

I hope you guys won’t kill me, but i think i forgot to say something: It’s important to do this using the bge!

So let’s start again:
I have an object. During the game, i would like to change the color of a object’s vertex_group.

Hope you can help me,

greetings

In the game engine… I’ve virtually no experience here, but what about just altering the material itself?