I'm trying to create a simple script that appends '.L' and '.R' to my existing vertex groups respectively. They already have an existing naming convention that begins with 'b__R' and 'b__L' and I don't want to change that, you can see that's actually an important part of my 'if'.
The mirror modifier does not recognise the L and R in its current format, so I just want to append the .L and .R then be able to remove it when I'm ready to import to my game. I want it to ignore central groups I have that do not have b__R/b__L in the name so that those just mirrors themselves into their existing groups.
Here's what I currently have, and it's not working:
import bpy obj = bpy.context.active_object vg = obj.vertex_groups[:] for g in vg: if g.name.beginswith(‘b__R’): g.name = g.name+’.R’ if g.name.beginswith(‘b__L’): g.name = g.name+’.L’
import bpy obj = bpy.context.active_object vg = obj.vertex_groups[:] for g in vg: if g.name.beginswith(‘b__R’): g.name = g.name.replace(’.R’,’’) if g.name.beginswith(‘b__L’): g.name = g.name.replace(’.L’,’’)
I am COMPLETELY unfamiliar with Python just keep that in mind, I'm just taking guesses here. I'm really just using Python as a means to an end and copied and edited the script from an answer to a similar question on here (linked below).
Also, importantly - your opinion. Is this the best way to do it? I already have an L and R with assigned weights and groups BEFORE deleting half of my mesh (in order to use the modifier). I'm working with a pre existing mesh here. Or should I delete the groups associated with the side of vertices I have deleted to use the modifier, then use the script to also CREATE the other side's groups again? I ask this because I'm not really sure how the data transfer works in the former case and whether those groups will be holding onto information from the deleted vertices.
If it turned out that the latter is the better way to do it (make the script create the other side's groups again), how would I do this?
Sorry for the load of questions, I've avoided this aspect of mirroring the weights in the past because I'm not too clear on its effects in my situation. I'm more than happy to answer any questions for clarification.