MetaFusion/Reference/SuperRiggingEditor/scripts/SGAddBlendShape.mel
2025-02-03 22:58:41 +08:00

35 lines
1.1 KiB
Plaintext

//******************************************************************************
//
// 版权所有: 玉溪时光科技有限公司
// 联系邮箱: q.100@qq.com
// 开发日期: 2024/09/16
//
//******************************************************************************
global proc SGAddBlendShape (string $targetName){
string $sel[] = `ls -sl`;
for ($i=0; $i<size($sel); $i++) {
for ($j=0; $j<50; $j++) {
string $meshe = `SGGetMeshes -m $j`;
if($sel[$i] == $meshe){
if($targetName != ""){
string $blendShape = `SGGetBlendShape $meshe`;
if(!`objExists $blendShape`){
$blendShape = `SGGetMeshes -i $j` + "_blendShapes";
blendShape -automatic -n $blendShape $meshe;
}
string $attrWeight = $blendShape + ".weight";
string $currentBlendShapeList[] = `listAttr -m $attrWeight`;
if(!stringArrayContains($targetName, $currentBlendShapeList)){
duplicate -rr -n $targetName $meshe;
int $targetIndex = `getAttr -size $attrWeight`;
blendShape -e -tc on -t $meshe $targetIndex $targetName 1 -w $targetIndex 0 $blendShape;
delete $targetName;
}
}
}
}
}
select -r $sel;
}