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