35 lines
1.0 KiB
Plaintext
35 lines
1.0 KiB
Plaintext
//******************************************************************************
|
|
//
|
|
// 版权所有: 玉溪时光科技有限公司
|
|
// 联系邮箱: q.100@qq.com
|
|
// 开发日期: 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;
|
|
}
|