#!/usr/bin/env python # -*- coding: utf-8 -*- import maya.cmds as cmds from scripts.utils.Core import GetMeshes, GetBlendShape, SetBlendShapes, ProgressBar def range_blend_shape_all(range_value): """ 为所有网格的混合变形器设置范围值 参数: range_value (float): 要设置的范围值 """ # 遍历前50个网格 for i in range(50): # 获取当前索引的网格 mesh = GetMeshes(m=i) if cmds.objExists(mesh): # 获取网格的混合变形器 blend_shape = GetBlendShape(mesh) if cmds.objExists(blend_shape): # 获取所有权重属性 bs_names = cmds.listAttr(f"{blend_shape}.weight", m=True) count = len(bs_names) # 显示进度 ProgressBar(sp=True) ProgressBar(max_value=count) # 处理每个混合变形目标 for j in range(count): # 检查是否取消 if cmds.progressWindow(query=True, isCancelled=True): break # 更新进度 ProgressBar(t=f"[{j+1}/{count}] {blend_shape}") ProgressBar(apr=1) # 重新生成目标并设置范围 bs_name = cmds.sculptTarget( blend_shape, e=True, regenerate=True, target=j ) SetBlendShapes(r=range_value, value=bs_name[0]) cmds.delete(bs_name) # 结束进度显示 ProgressBar(ep=True) # 如果直接运行此脚本 if __name__ == '__main__': pass