删除空顶点组
import bpy
def make_group_list():
obj = []
temp_list = []
group_list = []
so = bpy.context.selected_objects
for i in so:
obj.append(i)
for i in obj:
#I've used .extend here (with square brackets) to add every item to the list
temp_list.extend([group[0] for group in i.vertex_groups.items()])
for group_name in temp_list:
if group_name not in group_list:
group_list.append(group_name)
return group_list
#2. CHECK THE AVERAGE WEIGHT OF EACH VERTEX POINT
def average_weight(vertex_group_names, obj):
mesh = obj.data
for vertex in mesh.vertices:
for group in vertex.groups:
if group.group in vertex_group_names and group.weight > 0.1:
return False
return True
#3. DELETE THE GROUP
def delete_group(obj, vertex_group):
obj.vertex_groups.remove(vertex_group)
# GROUP_LIST DEFINED
group_list = make_group_list()
#4. MAIN FOR LOOP
for obj in bpy.context.selected_objects:
for vertex_group_name in group_list:
vertex_group = obj.vertex_groups.get(vertex_group_name)
if vertex_group is not None:
if average_weight([vertex_group.index], obj):
delete_group(obj,vertex_group)
复制shapeKey
import bpy
l=[]
obj = bpy.data.objects['Neutral.001']
#obj = bpy.context.active_object
#for i in obj.vertex_groups:
# print(i.name)
for i in obj.data.shape_keys.key_blocks:
print(i.name)
if ('brow' in i.name):
l.append(i.name)
obj = bpy.context.active_object
for i in l:
obj.shape_key_add(name=i, from_mix=False)
自带
import bpy
childrenList = bpy.data.objects['ShapeKeyModelGrp'].children
for child in childrenList:
bpy.ops.object.select_all(action='DESELECT')
child.select_set(True)
objectToSelect = bpy.data.objects["Neutral"]
objectToSelect.select_set(True)
bpy.context.view_layer.objects.active = objectToSelect
bpy.ops.object.join_shapes()