60 lines
1.7 KiB
Python
60 lines
1.7 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_select(mesh_indices, target_indices, range_value):
|
||
|
"""
|
||
|
为选定的网格和目标设置混合变形器范围值
|
||
|
Args:
|
||
|
mesh_indices (list): 网格索引列表
|
||
|
target_indices (list): 目标索引列表
|
||
|
range_value (float): 要设置的范围值
|
||
|
"""
|
||
|
count = len(mesh_indices)
|
||
|
|
||
|
# 初始化进度条
|
||
|
cmds.SGProgressBar(sp=True)
|
||
|
cmds.SGProgressBar(max=count)
|
||
|
|
||
|
# 处理每个网格和目标
|
||
|
for i in range(count):
|
||
|
mesh_index = mesh_indices[i]
|
||
|
target_index = target_indices[i]
|
||
|
|
||
|
# 获取网格
|
||
|
mesh = cmds.SGGetMeshes(m=mesh_index)
|
||
|
|
||
|
if cmds.objExists(mesh):
|
||
|
# 获取混合变形器
|
||
|
blend_shape = cmds.SGGetBlendShape(mesh)
|
||
|
|
||
|
if cmds.objExists(blend_shape):
|
||
|
# 重新生成目标并设置范围
|
||
|
bs_name = cmds.sculptTarget(
|
||
|
blend_shape,
|
||
|
e=True,
|
||
|
regenerate=True,
|
||
|
target=target_index
|
||
|
)
|
||
|
|
||
|
cmds.SGSetBlendShapes(r=range_value, value=bs_name[0])
|
||
|
cmds.delete(bs_name)
|
||
|
|
||
|
# 更新进度条
|
||
|
title = f"[{i+1}/{count}]Select Target Mesh..."
|
||
|
cmds.SGProgressBar(t=title)
|
||
|
cmds.SGProgressBar(apr=1)
|
||
|
|
||
|
# 结束进度条
|
||
|
cmds.SGProgressBar(ep=True)
|
||
|
|
||
|
# 如果直接运行此脚本
|
||
|
if __name__ == '__main__':
|
||
|
pass
|