目录
mel指令 删除父节点
string $parentNodeName = "f_avg_root";
string $children[] = `listRelatives -children $parentNodeName`;
for ($child in $children) {
parent -w $child;
}
delete $parentNodeName;
mel指令 设置t-pose
select -r f_avg_Pelvis f_avg_L_Hip f_avg_L_Knee f_avg_L_Ankle f_avg_L_Foot f_avg_R_Hip f_avg_R_Knee f_avg_R_Ankle f_avg_R_Foot f_avg_Spine1 f_avg_Spine2 f_avg_Spine3 f_avg_Neck f_avg_Head f_avg_L_Collar f_avg_L_Shoulder f_avg_L_Elbow f_avg_L_Wrist f_avg_L_Hand f_avg_R_Collar f_avg_R_Shoulder f_avg_R_Elbow f_avg_R_Wrist f_avg_R_Hand ;
string $selToTpose[] =`ls -sl`;
for ($each in $selToTpose)
{
setAttr ($each +".r") 0 0 0 ;
setKeyframe $each;
}
currentTime 0 ;
python指令 测试ok
import maya.cmds as cmds
node_name="f_avg_root"
# 假定父节点的名称是 "parent_node"
children = cmds.listRelatives(node_name, children=True) or []
# 解除父级关系,使子节点成为顶级节点
for child in children:
cmds.parent(child, world=True)
# 删除父节点
cmds.delete(node_name)
一键选择所有的子节点
把这个mel指令拖拽到工具架里面,取个名字,
调用方法:选择根节点,然后点击按钮,就全选所有子节点了。
// 获取当前选中的节点列表,选择第一个节点作为父节点
string $selection[] = `ls -sl`;
if (size($selection) > 0) {
string $parentNode = $selection[0];
// 选中父节点和其所有子节点
select -r -hi $parentNode;
} else {
print("No objects selected. Please select a parent node first.\n");
}
FBX批量删除父节点
自动创建父目录
global proc processMotionCaptureData() {
string $sourcePath = "E:/20240326/output/";
string $outputPath = "E:/20240326/output1/";
string $fbxFiles[];
if (!`filetest -d $outputPath`) {
// mkdir has parent dir
string $command = "mkdir \"" + $outputPath + "\"";
system($command);
// string $command = "mkdir -p \"" + $outputPath + "\"";
// system($command);
}
$fbxFiles = `getFileList -folder $sourcePath -filespec "*.fbx"`;
for ($file in $fbxFiles)
{
string $sourceFile = ($sourcePath + "/" + $file);
file -import -type "FBX" -ignoreVersion -ra true -mergeNamespacesOnClash false -namespace "_tempNamespace" -options "fbx" -pr -importTimeRange "combine" $sourceFile;
currentTime 0 ;
select -r f_avg_Pelvis ;
parent -w;
delete f_avg_root;
select -cl;
string $outputFileName = $file;
file -force -options "groups=1;ptgroups=1;materials=1;smoothing=1;normals=1" -type "FBX export" -pr -ea ($outputPath + "/" + $outputFileName);
}
}
processMotionCaptureData();