70 lines
2.2 KiB
Python
70 lines
2.2 KiB
Python
#!/usr/bin/env python
|
|
# -*- coding: utf-8 -*-
|
|
|
|
"""
|
|
版权所有: 深圳时光科技有限公司
|
|
联系方式: q.100@qq.com
|
|
创建日期: 2023/08/08
|
|
"""
|
|
|
|
import maya.cmds as cmds
|
|
|
|
def sg_range_blend_shape_all(range_value):
|
|
"""
|
|
为所有网格的混合变形器设置范围值
|
|
Args:
|
|
range_value (float): 要设置的范围值
|
|
"""
|
|
# 遍历前50个网格
|
|
for i in range(50):
|
|
# 获取当前索引的网格
|
|
mesh = cmds.SGGetMeshes(m=i)
|
|
|
|
if cmds.objExists(mesh):
|
|
# 获取网格的混合变形器
|
|
blend_shape = cmds.SGGetBlendShape(mesh)
|
|
|
|
if cmds.objExists(blend_shape):
|
|
# 获取所有权重属性
|
|
bs_names = cmds.listAttr(f"{blend_shape}.weight", m=True)
|
|
count = len(bs_names)
|
|
|
|
# 创建进度窗口
|
|
cmds.progressWindow(
|
|
title="Set Range Target",
|
|
min=0,
|
|
max=count,
|
|
isInterruptable=True
|
|
)
|
|
|
|
# 处理每个混合变形目标
|
|
for j in range(count):
|
|
# 检查是否取消操作
|
|
if cmds.progressWindow(query=True, isCancelled=True):
|
|
break
|
|
|
|
# 重新生成目标并设置范围
|
|
bs_name = cmds.sculptTarget(
|
|
blend_shape,
|
|
e=True,
|
|
regenerate=True,
|
|
target=j
|
|
)
|
|
|
|
cmds.SGSetBlendShapes(r=range_value, value=bs_name[0])
|
|
cmds.delete(bs_name)
|
|
|
|
# 更新进度窗口
|
|
status = f"[{j+1}/{count}] {blend_shape}"
|
|
cmds.progressWindow(
|
|
edit=True,
|
|
progress=j,
|
|
status=status
|
|
)
|
|
|
|
# 关闭进度窗口
|
|
cmds.progressWindow(endProgress=True)
|
|
|
|
# 如果直接运行此脚本
|
|
if __name__ == '__main__':
|
|
pass |