MetaFusion/Reference/SuperRiggingEditor/scripts/SGUpdateCtrl.mel

35 lines
1.0 KiB
Plaintext
Raw Normal View History

2025-02-03 22:58:41 +08:00
//******************************************************************************
//
// <20><>Ȩ<EFBFBD><C8A8><EFBFBD><EFBFBD>: <20><>Ϫʱ<CFAA><CAB1><EFBFBD>Ƽ<EFBFBD><C6BC><EFBFBD><EFBFBD>޹<EFBFBD>˾
// <20><>ϵ<EFBFBD><CFB5><EFBFBD><EFBFBD>: q.100@qq.com
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: 2024/10/28
//
//******************************************************************************
global proc SGUpdateCtrl (string $json, int $index){
string $selList[] = `ls -sl`;
string $object[] = `SGReadJson -f $json -t "object"`;
if(size($object) < 61){
error -n "Insufficient number of JSON file objects.";
return;
}
string $attrs[] = {"translateX","translateY","translateZ","rotateX","rotateY","rotateZ"};
string $data = "{}";
for($sel in $selList){
string $attributes[] = `listAttr -keyable $sel`;
for($attr in $attrs){
string $attribute = $sel + "." + $attr;
if(stringArrayContains($attr, $attributes)) {
float $value = `getAttr $attribute`;
if($value > 0.001 || $value < -0.001){
$data = `SGWriteJson -d $data -k $attribute -t "double" $value`;
}
}
}
}
$object[$index] = $data;
SGWriteJson -of $json -sf $json -t "object" $object;
}