blender 面捕优化
删除空顶点组
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()
本文作者:Nolca
本文链接:https://www.cnblogs.com/nolca/p/17476567.html
版权声明:本作品采用 收益分享revenue sharing 许可协议进行许可。
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步