Last active
November 11, 2021 05:42
-
-
Save yshwaker/49920190a564a76b8e16d153cef89872 to your computer and use it in GitHub Desktop.
create mirror of active vertex group as a new vertex group
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import bpy | |
bpy.ops.object.vertex_group_copy() | |
bpy.ops.object.vertex_group_mirror(flip_group_names=False,use_topology=True) | |
# only select one object at a time | |
selected_obj = bpy.context.selected_objects[0] | |
active_vertex_group = selected_obj.vertex_groups.active | |
if active_vertex_group.name.find('_L_') != -1: | |
print(1) | |
active_vertex_group.name = active_vertex_group.name.replace('_L_', '_R_').replace('_copy', '') | |
elif active_vertex_group.name.find('_R_') != -1: | |
print(2) | |
active_vertex_group.name = active_vertex_group.name.replace('_R_', '_L_').replace('_copy', '') | |
# change all | |
import bpy | |
selected_obj = bpy.context.selected_objects[0] | |
vertex_groups = selected_obj.vertex_groups | |
ops = bpy.ops.object | |
for group in vertex_groups: | |
if group.name.find('_L_') != -1: | |
bpy.ops.object.vertex_group_set_active(group = group.name) | |
ops.vertex_group_copy() | |
ops.vertex_group_mirror(flip_group_names=False,use_topology=True) | |
vertex_groups.active.name = vertex_groups.active.name.replace('_L_', '_R_').replace('_copy', '') | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment