get SkinCluster from mesh
string $SkinSkinCluster = `findRelatedSkinCluster $mesh`;
応用例
print(">>>>>>>>>>>>>SkinWeightCheck Start>>>>>>>>>>\n");
select "|parts_low";
string $selected[] = `ls -sl -long -absoluteName`;
string $selectedStr = stringArrayToString($selected, ","); // ","を区切り文字として結合する
print("SkinWeightCheckの 選択したもの $selected= "+$selectedStr+"\n");
string $mesh[];
for ($sel in $selected) {
string $allMesh[] = `listRelatives -ni -pa -ad -typ "mesh" $sel`;
for ($am in $allMesh) {
string $trans[] = `listRelatives -ni -pa -p $am`;
$mesh[size($mesh)] = $trans[0];
}
}
$mesh = stringArrayRemoveDuplicates($mesh);
string $meshStr = stringArrayToString($mesh, ","); // ","を区切り文字として結合する
print("SkinWeightCheckの メッシュのみ選別したもの $mesh= "+$meshStr+"\n");
for ($mesh_i in $mesh){
//print("$mesh_i= "+$mesh_i+"\n");
string $SkinCluster = `findRelatedSkinCluster $mesh_i`;
print("メッシュ : "+$mesh_i+" SkinCluster : "+$SkinCluster+" \n");
//string $influenceJoint[] = `skinCluster -q -influence $mesh_i`;
string $influenceJoint[];
int $inflenceJointBool=0;
if ( catch ($influenceJoint=`skinCluster -q -influence $mesh_i`)) {
print("B ------------------------------------------------------------------------------->>>>>メッシュ : "+$mesh_i+" のインフルエンスジョイントがありません!!NG \n");
$inflenceJointBool=1;
$AllWeightMeshBool=1;
}else{
print("A OK \n");
$inflenceJointBool=0;
}
int $WeightMeshBool=0;
if($inflenceJointBool==0){
print("メッシュ : "+$mesh_i+" influenceJoint : "+$influenceJoint[0]+" \n");
//vtx[100] の joint1 の weight を取得
//skinPercent( 'skinCluster1', 'pPlane1.vtx[100]', t='joint1', query=True, value=True)
//string $weight[] = `skinPercent -query -value -t $influence[0] $SkinCluster $mesh `;
string $vertex = $mesh_i+".vtx[0]" ;
//string $weight[] = `skinPercent -query -value $vertex $SkinCluster`;
float $weightFloatArr[] = `skinPercent -query -value $SkinCluster $vertex`;
print("$weightFloatArr= "+floatArrayToString($weightFloatArr, ", ")+"\n");
//skinPercent -query -value skinCluster1 pPlane1.vtx[100];
float $weightAll=0;
for ($val in $weightFloatArr){
$weightAll=$weightAll + $val;
}
print("$weightAll= "+$weightAll+"\n");
if($weightAll>0){
print("SkinWeight OK !!! $mesh_i= "+$mesh_i+" OK!!!!!\n");
}else{
$WeightMeshBool=1;
print("SkinWeight -----------------------------------------------------------スキンウェイトがありません--Attention !!! $mesh_i= "+$mesh_i+" NG!!!!!\n");
}
$AllWeightMeshBool=$AllWeightMeshBool+$WeightMeshBool;
}
}//for
参考
[maya][python] findRelatedskinCLuster
https://discourse.techart.online/t/maya-python-findrelatedskincluster/2673