skinWeight Mesh Combine
mesh> combine option
MELだと
string $combine[] = `polyUniteSkinned -constructionHistory 0 -mergeUVSets 1`;
参考URL
https://help.autodesk.com/cloudhelp/2023/JPN/Maya-Tech-Docs/Commands/polyUniteSkinned.html
skinWeight Mesh Combine
mesh> combine option
MELだと
string $combine[] = `polyUniteSkinned -constructionHistory 0 -mergeUVSets 1`;
参考URL
https://help.autodesk.com/cloudhelp/2023/JPN/Maya-Tech-Docs/Commands/polyUniteSkinned.html
edgeToEdgeLoopSkinWeightHanmer
global proc edgeToEdgeLoopSkinWeightHanmer(){
SelectEdgeLoopSp;
//polySelectSp -loop;
ConvertSelectionToVertices;
WeightHammer;
}
edgeToEdgeLoopSkinWeightHanmer()
[maya][mel] Check if a file is read-only in MEL.
global proc MEL_FileReadModeCheck(string $Save_path){
//MELでファイルの読み取り専用をチェックする。
print("MEL_FileReadModeCheck("+$Save_path+") \n");
python("import os");
int $FileReadOnlybool = python("os.access('"+$Save_path+"', os.W_OK)");
print("$FileReadOnlybool= "+$FileReadOnlybool+" \n");
if($FileReadOnlybool==0){
print("読み取り専用 のため書き込み不可 \n");
}else{
print("書き込み出来ます \n");
}
}
MEL_FileReadModeCheck("D:/check_ON.txt");
MEL_FileReadModeCheck("D:/check_OFF.txt");
maya mel get mesh from material
hyperShade -objects materialName;
//結果のmeshは選択される
Function
global proc string get_MeshTransform_from_Material_v2(string $mat){
string $selected[];
//選択を取っておく
$selected =`ls -sl`;
string $mesh_arr[];
//$mesh_arr =`hyperShade -objects $mat`;
//結果のmeshは選択されるので
hyperShade -objects $mat;
//選択からとる
$mesh_arr =`ls -sl`;
int $mesh_arr_len=size($mesh_arr);
string $returnStr;
print("$mesh_arr_len= "+$mesh_arr_len+"\n");
if($mesh_arr_len==0){
$returnStr="";
}else{
print("$mesh_arr= "+ stringArrayToString($mesh_arr, ", ") +"\n");
string $mesh= $mesh_arr[0];
string $trans_arr[] = `listRelatives -noIntermediate -fullPath -parent $mesh`;
print("$trans_arr= "+ stringArrayToString($trans_arr, ", ") +"\n");
$returnStr=$trans_arr[0];
}
//選択を戻す
select -cl;
string $sel;
for($sel in $selected){
select -add $sel;
};
return $returnStr;
}
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
あるようで知らない特殊な複製。
// 選択したノードに至る上流ノード (およびその接続) も複製されます。
// スキンウェイトなどもコピーされます。
duplicate -upstreamNodes;
上記の場合
duplicate -returnRootsOnly -upstreamNodes;
group root1 parts_low1;
カスタムした例
global proc skinWeightCopy_JointMeshGroup(){
//選択
select root parts_low;
//スキンウェイトモデルのスキンウェイトごとコピー
duplicate -returnRootsOnly -upstreamNodes;
//グループ化
group -name "group_dup" root1 parts_low1;
//元の名前にリネーム
rename "group_dup|root1" "root";
rename "group_dup|parts_low1" "parts_low";
}
skinWeightCopy_JointMeshGroup();
combine しながらエクスポート
global proc skinWeightCopy_JointMeshGroup(){
//選択
select "|root" "|parts_low";
//スキンウェイトモデルのスキンウェイトごとコピー
duplicate -returnRootsOnly -upstreamNodes;
//グループ化
group -name "group_dup" root1 parts_low1;
//元の名前にリネーム
rename "group_dup|root1" "root";
rename "group_dup|parts_low1" "parts_low";
}
global proc group_dup_parts_low_combine(){
string $selected[] = `ls -sl -long -absoluteName`;
//string $selectedStr = stringArrayToString($selected, ","); // ","を区切り文字として結合する
//print("選択したもの $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(" メッシュのみ選別したもの $mesh= "+$meshStr+"\n");
select -r $mesh; // <メッシュのみ選択
// Combine実行
// Skeletalだった場合
string $combine[] = `polyUniteSkinned -ch 0 -muv 1`;
rename $combine[0] "MeshGP";
//よけておくグループ化
select "|root" "parts_low";
string $group_root;
$group_root =`group -world -name "group_root"`;
//MeshGPをparts_lowへ入れる
select "MeshGP";
string $group_parts_low;
$group_parts_low =`group -world -name "parts_low"`;
//worldへ移動
parent -world "group_dup|root";
//出力用選択
select "|root" "|parts_low";
// Export
// --------------------------------------------------------------------------
simple_model_common_Export(2, "D:/MOSADesign/WorkData/Avatar/008/001/PL_008_001_001/Game/SK_PL_008_001_001_Body.fbx", 0);
//おかたずけ partslow|MeshGP rootを削除
delete "|parts_low" "|root" "|group_dup";
//worldへ移動
parent -world "group_root|root";
//worldへ移動
parent -world "group_root|parts_low";
//group_root 削除
delete "|group_root";
}
// Export
//--------------------------------------------------------------------------
global proc simple_model_common_Export(int $type, string $expName, int $modelType) {
showHidden -a;
// if($type == 2) {
if ($type == 1) {
FBXExportSmoothMesh -v 0;
} else {
FBXExportSmoothMesh -v 1;
}
FBXExportAnimationOnly -v 0;
FBXExportInAscii -v 0 ;
FBXExportConvertUnitString cm;
FBXExportTriangulate -v 0;
FBXExportSmoothingGroups -v 1;
FBXExportConstraints -v 0;
FBXExport -f $expName -s;
}
参考URL
https://help.autodesk.com/cloudhelp/2025/ENU/Maya-Tech-Docs/Commands/duplicate.html
http://me.autodesk.jp/wam/maya/docs/Maya2010/Commands/duplicate.html
maya python How can I enter a regular expression for search from the created text field?
import maya.cmds as cmds
import re
def search_objects_by_regex(*args):
# テキストフィールドから正規表現を取得
regex_pattern = cmds.textField("regexField", query=True, text=True)
# シーン内のすべてのオブジェクトを取得
all_objects = cmds.ls()
# 正規表現パターンをコンパイル
try:
regex = re.compile(regex_pattern)
except re.error as e:
cmds.warning(f"Invalid regex pattern: {e}")
return
# 正規表現に一致するオブジェクトをフィルタリング
matching_objects = [obj for obj in all_objects if regex.search(obj)]
# 結果を表示
if matching_objects:
cmds.confirmDialog(title='Search Results', message='\n'.join(matching_objects))
else:
cmds.confirmDialog(title='Search Results', message='No matching objects found.')
# UIの作成
if cmds.window("regexSearchWindow", exists=True):
cmds.deleteUI("regexSearchWindow")
cmds.window("regexSearchWindow", title="Regex Search", widthHeight=(300, 100))
cmds.columnLayout(adjustableColumn=True)
cmds.text(label="Enter Regex Pattern:")
cmds.textField("regexField")
cmds.button(label="Search", command=search_objects_by_regex)
cmds.showWindow("regexSearchWindow")
検索置換の場合
import maya.cmds as cmds
import re
def replace_objects_by_regex(*args):
# テキストフィールドから正規表現と置換文字列を取得
regex_pattern = cmds.textField("regexField", query=True, text=True)
replace_text = cmds.textField("replaceField", query=True, text=True)
# シーン内のすべてのオブジェクトを取得
all_objects = cmds.ls()
# 正規表現パターンをコンパイル
try:
regex = re.compile(regex_pattern)
except re.error as e:
cmds.warning(f"Invalid regex pattern: {e}")
return
# 正規表現に一致するオブジェクトを置換
replaced_objects = [regex.sub(replace_text, obj) for obj in all_objects]
# 結果を表示
if replaced_objects:
cmds.confirmDialog(title='Replace Results', message='\n'.join(replaced_objects))
else:
cmds.confirmDialog(title='Replace Results', message='No objects replaced.')
# UIの作成
if cmds.window("regexReplaceWindow", exists=True):
cmds.deleteUI("regexReplaceWindow")
cmds.window("regexReplaceWindow", title="Regex Replace", widthHeight=(300, 150))
cmds.columnLayout(adjustableColumn=True)
cmds.text(label="Enter Regex Pattern:")
cmds.textField("regexField")
cmds.text(label="Enter Replace Text:")
cmds.textField("replaceField")
cmds.button(label="Replace", command=replace_objects_by_regex)
cmds.showWindow("regexReplaceWindow")
import unreal
class hoge:
def show_messageDialog(self):
title="タイトル"
message="メッセージ"
message_type=unreal.AppMsgType.OK_CANCEL
unreal.EditorDialog.show_message(title,message,message_type, default_value=unreal.AppReturnType.NO, message_category=unreal.AppMsgCategory.WARNING)
class_Ins=hoge()
hoge.show_messageDialog()
参考URL
https://docs.unrealengine.com/5.3/en-US/PythonAPI/class/EditorDialog.html#unreal.EditorDialog
import maya.cmds as cmds
import pymel.core as pm
import os
def remap_selected_texture(z_path):
# figure out what's selected
selected = pm.ls(sl=True)
workspace_path = cmds.workspace(query=True, rootDirectory=True)
print("workspace_path= "+workspace_path)
for item in selected:
test_path = pm.getAttr(item+".ftn")
fileName = test_path.split('/')[-1]
fileName = fileName.replace('//', '')
fileName = fileName.replace('/', '')
print("fileName2= "+fileName)
#if ':' not in test_path:
if(fileName=="GraceYong_ArmsColorD1001.jpg"):
fileName="GraceYong_ArmsColorD_1001.jpg"
if (1==1):
#print("fileName1= "+fileName)
#new_path = os.path.join(z_path, 'cartoon_room', second)
new_path = os.path.join(workspace_path,z_path, fileName)
new_path = new_path.replace('\\', '/')
new_path = new_path.replace('//', '/')
relative_path = os.path.join(z_path, fileName)
relative_path = relative_path.replace('\\', '/')
new_path = new_path.replace('//', '/')
if os.path.exists(new_path):
if(fileName==""):
print("item= "+str(item)+" is No fileName= "+ fileName)
cmds.select( str(item), r=True )
cmds.delete( str(item) )
else:
print("new_path= "+new_path+' is exists! OK')
pm.setAttr(item+'.ftn', new_path)
#pm.setAttr(item+'.ftn', relative_path)
else:
print("new_path= "+new_path+ ' not exists NG' )
if os.path.exists(test_path):
pass
else:
PersonalIndex=test_path.find("Personal")
if(PersonalIndex==-1):
pass
else:
print("test_path= "+test_path+ ' not exists NG' )
pm.setAttr(item+'.ftn', "")
cmds.select( str(item), r=True )
cmds.delete( str(item) )
cmds.select(selected)
print("--------------remap_selected_texture----------END")
remap_selected_texture("GraceYong.images")
モデルフォルダの自動認識と出力フォルダ引数のパターン
#remap_selected_filenode_texture_path
import maya.cmds as cmds
import pymel.core as pm
import os
def remap_selected_texture(z_path):
# figure out what's selected
selected = pm.ls(sl=True)
# workspace_project_path
workspace_path = cmds.workspace(query=True, rootDirectory=True)
print("workspace_path= "+workspace_path)
# ma_file_path
ma_file_path=cmds.file(q=True, sn=True)
print("ma_file_path= "+ma_file_path)
ma_file_path_arr = ma_file_path.split('/')
ma_Folder=ma_file_path_arr[-2]
print("ma_Folder= "+ma_Folder)
for item in selected:
item_path = pm.getAttr(item+".ftn")
print("item_path= "+item_path)
item_path_arr = item_path.split('/')
texFolderName = item_path_arr[-2]
print("texFolderName= "+texFolderName)
fileName = item_path_arr[-1]
print("fileName= "+fileName)
fileName = fileName.replace('//', '')
fileName = fileName.replace('/', '')
print("fileName2= "+fileName)
#if ':' not in test_path:
if (1==1):
#print("fileName1= "+fileName)
#new_path = os.path.join(z_path, 'cartoon_room', second)
new_path = os.path.join(workspace_path,z_path, fileName)
new_path = new_path.replace('\\', '/')
new_path = new_path.replace('//', '/')
#relative_path = os.path.join(z_path, fileName)
#====================================================
relative_path = ma_Folder+"/"+z_path+"/"+fileName
#====================================================
print("relative_path= "+relative_path)
#relative_path = relative_path.replace('\\', '/')
abs_path = os.path.abspath(workspace_path+"/"+relative_path)
abs_path = abs_path.replace('//', '/')
print(" abs_path= "+abs_path)
new_path= abs_path
print(" new_path= "+new_path)
print("----------------------------end--------------------------")
if os.path.exists(new_path):
if(fileName==""):
print("item= "+str(item)+" is No fileName= "+ fileName)
cmds.select( str(item), r=True )
cmds.delete( str(item) )
else:
print("new_path= "+new_path+' is exists! OK')
pm.setAttr(item+'.ftn', new_path)
else:
print("new_path= "+new_path+ ' not exists NG' )
cmds.select(selected)
print("--------------remap_selected_texture----------END")
remap_selected_texture("texture")
Scene押してシーンディレクトリ取得、押してWalkでテクスチャファイルをwalkで自動検索
#remap_selected_filenode_texture_path
import maya.cmds as cmds
import pymel.core as pm
import os
def dir_walk(walkDir,TextureFileName):
resultPath=""
for curDir, dirs, files in os.walk(walkDir):
print('===================')
print("現在のディレクトリ: " + curDir)
curDir=curDir.replace("\\","/")
curDir_arr=curDir.split("/")
curDir_endDirName = curDir_arr[-1]
print("curDir_endDirName= "+curDir_endDirName)
if(curDir_endDirName==".mayaSwatches"):
print("処理をスキップします。。。")
pass
else:
print("内包するディレクトリ:" + str(dirs))
print("内包するファイル: " + str(files))
for fileName in files:
if(fileName==TextureFileName):
print("Hit : fileName= "+fileName+ "== TextureFileName= "+TextureFileName)
resultPath=curDir+"/"+fileName
print('===================')
return resultPath
def remap_selected_texture2(sceme_path):
# figure out what's selected
selected = cmds.ls(sl=True)
# workspace_project_path
workspace_path = cmds.workspace(query=True, rootDirectory=True)
print("workspace_path= "+workspace_path)
# ma_file_path
ma_file_path=cmds.file(q=True, sn=True)
print("ma_file_path= "+ma_file_path)
ma_file_path_arr = ma_file_path.split('/')
ma_Folder=ma_file_path_arr[-2]
print("ma_Folder= "+ma_Folder)
for item in selected:
item_path = cmds.getAttr(item+".ftn")
print("item_path= "+item_path)
item_path_arr = item_path.split('/')
texFolderName = item_path_arr[-2]
print("texFolderName= "+texFolderName)
fileName = item_path_arr[-1]
print("fileName= "+fileName)
fileName = fileName.replace('//', '')
fileName = fileName.replace('/', '')
print("fileName2= "+fileName)
fixTexturePath=dir_walk(sceme_path,fileName)
print("fixTexturePath= "+fixTexturePath)
#if ':' not in test_path:
if (1==1):
#print("fileName1= "+fileName)
#new_path = os.path.join(z_path, 'cartoon_room', second)
#new_path = os.path.join(workspace_path,z_path, fileName)
new_path = fixTexturePath
new_path = new_path.replace('\\', '/')
new_path = new_path.replace('//', '/')
#relative_path = os.path.join(z_path, fileName)
#====================================================
#relative_path = ma_Folder+"/"+z_path+"/"+fileName
#====================================================
#print("relative_path= "+relative_path)
#relative_path = relative_path.replace('\\', '/')
#abs_path = os.path.abspath(workspace_path+"/"+relative_path)
#abs_path = abs_path.replace('//', '/')
#print(" abs_path= "+abs_path)
#new_path= abs_path
print(" new_path= "+new_path)
print("----------------------------end--------------------------")
if os.path.exists(new_path):
if(fileName==""):
print("item= "+str(item)+" is No fileName= "+ fileName)
cmds.select( str(item), r=True )
cmds.delete( str(item) )
else:
print("new_path= "+new_path+' is exists! OK')
#cmds.setAttr(item+'.ftn', new_path)
cmds.setAttr(item+'.fileTextureName', new_path,type='string')
else:
print("new_path= "+new_path+ ' not exists NG' )
cmds.select(selected)
print("--------------remap_selected_texture----------END")
def remap_fileNode_texture(self):
text_Field_id="remap_selected_filenode_texture_path_Window|USD_layout|pathTxtFld"
textField_outputFolder = cmds.textField(text_Field_id, q=True, text=True)
remap_selected_texture2(textField_outputFolder)
def get_scenePath():
scenefilePath = cmds.file(q=1, sceneName=1)
mayaPath,mayaFile = os.path.split(scenefilePath)
#mayaPath = mayaPath + "/Usd/"
#mayaPath = mayaPath + "/"
mayaPath=os.path.abspath(mayaPath)
mayaPath=mayaPath.replace('\\', '/')
print("mayaPath= "+mayaPath)
mayaPath_len=len(mayaPath)
last_str=mayaPath[mayaPath_len-1:]
print("mayaPath= "+mayaPath+ " last_str= "+last_str)
if(last_str=="/"):
pass
else:
mayaPath=mayaPath+"/"
return mayaPath
def btn_scene(self):
scenePath = get_scenePath()
#textureFolder= cmds.textField('textField_outputFolder', q=True, text=True)
#lastExportDirPath=scenePath+textureFolder+"/"
set_lastExportDirPath(scenePath)
def set_lastExportDirPath(lastExportDirPath):
selectList=cmds.ls(sl=True)
if(str(selectList)== "[]"):
print("なにも選択されていません。0 set_lastExportDirPath")
text_Field_id="remap_selected_filenode_texture_path_Window|USD_layout|pathTxtFld"
cmds.textField(text_Field_id, edit=True, text=lastExportDirPath)
cmds.select(selectList)
def createWindow():
scenefilePath = cmds.file(q=1, sceneName=1)
USD_window = cmds.window("remap_selected_filenode_texture_path_Window", widthHeight=(400, 200))
USD_layout = cmds.columnLayout("USD_layout",adjustableColumn=True, parent=USD_window)
cmds.text (label="選択したハイパーシェードのテクスチャのパスを置換するツールです。", align='left', parent=USD_layout)
cmds.text (label="シーンのパス以下のフォルダーから検索して自動的に置換します。", align='left', parent=USD_layout)
cmds.separator(parent=USD_layout)
cmds.text (label="", align='left', parent=USD_layout)
cmds.text (label="1、Sceneを押してください。", align='left', parent=USD_layout)
cmds.button(label="Scene", command=btn_scene, parent=USD_layout)
text_field = cmds.textField("pathTxtFld", parent="USD_layout",text="")
#cmds.text (label="2、テクスチャフォルダ名を指定してください。", align='left', parent=USD_layout)
#text_field = cmds.textField("textField_outputFolder", parent="USD_layout",text="texture")
cmds.separator(parent=USD_layout)
cmds.text (label="", align='left', parent=USD_layout)
cmds.text (label="2、HyperShadeのテクスチャTabで(例:file1,file2,複数可)を選択して、ボタンを押してください。", align='left', parent=USD_layout)
#CheckBox_Absolute_Path_Bool = cmds.checkBox('CheckBox_Absolute_Path', q=True, value=True)
cmds.button(label="Remap FileNode Texture ", command=remap_fileNode_texture, parent=USD_layout)
#cmds.separator(parent=USD_layout)
#cmds.button(label="Add USD Referernce/Payload... ", command=add_prim_xform_for_stage_layer, parent=USD_layout)
cmds.showWindow(USD_window)
return None
def remap_selected_filenode_texture_path():
if cmds.window("remap_selected_filenode_texture_path_Window",exists=True):
cmds.deleteUI("remap_selected_filenode_texture_path_Window")
createWindow()
remap_selected_filenode_texture_path()
Meshグループに無数にMeshがはいっててスキンウェイトをコピーするのがめんどくさくなったから書いたよ
Aのメッシュグループから
Bのメッシュグループにコピーしていく
動作はちょっと逆で
Bのグループのメッシュ名をループして
Aのグループのメッシュ名にあるか探す
あったらスキンウェイトコピー
なかったらrejectedリストに入れてます。
最後にrejectedListを表示するのでスキンウェイトしなかったメッシュのリストが出ます。
// SkinWeightCopy First Select MeshGroup to Second Select MeshGroup
string $selectedArrFUllPath[] = `ls -long -sl`;
print($selectedArrFUllPath);
string $FirstSelect=$selectedArrFUllPath[0];
string $SecondSelect=$selectedArrFUllPath[1];
string $rejectArr[];
string $inputNodes[] = `ls -type transform -long -dag $FirstSelect`;
string $destNodes[] = `ls -type transform -long -dag $SecondSelect`;
$inputNodeslong=size($inputNodes);
$destNodeslong=size($destNodes);
string $buffer[];
string $buffer_i[];
$finded = 0;
for($d = 0; $d <$destNodeslong;$d++){
string $destNode_name=$destNodes[$d];
if($destNode_name==$SecondSelect){
}else{
print("$destNode_name= "+$destNode_name+"\n");
$numTokens = `tokenize $destNode_name "|" $buffer`;
$bufferlong=size($buffer);
string $destNode_name_Short = $buffer[$bufferlong-1]+"";
print("$destNode_name_Short= "+$destNode_name_Short+"\n");
$finded = 0;
for($i = 0; $i <$inputNodeslong;$i++){
string $inputNode_name=$inputNodes[$i];
$numTokens_i = `tokenize $inputNode_name "|" $buffer_i`;
$bufferlong_i=size($buffer_i);
string $inputNode_name_Short = $buffer_i[$bufferlong_i-1]+"";
print("$inputNode_name_Short= "+$inputNode_name_Short+"\n");
//$index=`gmatch $inputNode_name $destNode_name_Short`;
//if($index > 0){
if($inputNode_name_Short==$destNode_name_Short){
//$blendShapeName = $blendshapeRet_name;
print("$destNode_name= "+$destNode_name+" isHit!! "+"\n");
select -r $inputNode_name;
select -add $destNode_name;
copySkinWeights -noMirror -surfaceAssociation closestPoint -influenceAssociation closestJoint;
//copySkinWeights -noMirror -surfaceAssociation closestPoint -influenceAssociation closestJoint -sourceSkin $inputNode_name -destinationSkin $destNode_name;
$finded = 1;
}
}
if($finded==0){
$rejectArr[size($rejectArr)] = $destNode_name;
}
}
}
print("----rejected_list---start"+"\n");
print($rejectArr);
print("----rejected_list---end"+"\n");
select -r $FirstSelect ;
select -add $SecondSelect ;
メッシュグループ内のグループを無視できるように、MeshのTransformだけをフィルターした。
// SkinWeightCopy First Select MeshGroup to Second Select MeshGroup
string $selectedArrFUllPath[] = `ls -long -sl`;
print($selectedArrFUllPath);
string $FirstSelect=$selectedArrFUllPath[0];
string $SecondSelect=$selectedArrFUllPath[1];
string $rejectArr[];
//string $inputNodes[] = `ls -type transform -long -dag $FirstSelect`;
//string $destNodes[] = `ls -type transform -long -dag $SecondSelect`;
string $inputNodes_mesh[] = `ls -type mesh -long -dag $FirstSelect`;
string $destNodes_mesh[] = `ls -type mesh -long -dag $SecondSelect`;
$inputNodes_meshlong=size($inputNodes_mesh);
$destNodes_meshlong=size($destNodes_mesh);
string $inputNodes[];
string $destNodes[];
clear $inputNodes;
clear $destNodes;
string $mesh;
string $parent;
for($d0 = 0; $d0 <$inputNodes_meshlong;$d0++){
$mesh=$inputNodes_mesh[$d0];
string $parentS[] = `listRelatives -parent -path -type transform $mesh`;
$parent=$parentS[0];
$inputNodes[size($inputNodes)] = $parent;
}
for($d0 = 0; $d0 <$destNodes_meshlong;$d0++){
$mesh=$destNodes_mesh[$d0];
string $parentS[] = `listRelatives -parent -path -type transform $mesh`;
$parent=$parentS[0];
$destNodes[size($destNodes)] = $parent;
}
print("$inputNodes= ------------------------------------------------ \n");
print($inputNodes);
print("$destNodes= ------------------------------------------------ \n");
print($destNodes);
$inputNodeslong=size($inputNodes);
$destNodeslong=size($destNodes);
string $buffer[];
string $buffer_i[];
$finded = 0;
for($d = 0; $d <$destNodeslong;$d++){
string $destNode_name=$destNodes[$d];
if($destNode_name==$SecondSelect){
}else{
print("$destNode_name= "+$destNode_name+"\n");
$numTokens = `tokenize $destNode_name "|" $buffer`;
$bufferlong=size($buffer);
string $destNode_name_Short = $buffer[$bufferlong-1]+"";
print("$destNode_name_Short= "+$destNode_name_Short+"\n");
$finded = 0;
for($i = 0; $i <$inputNodeslong;$i++){
string $inputNode_name=$inputNodes[$i];
$numTokens_i = `tokenize $inputNode_name "|" $buffer_i`;
$bufferlong_i=size($buffer_i);
string $inputNode_name_Short = $buffer_i[$bufferlong_i-1]+"";
print("$inputNode_name_Short= "+$inputNode_name_Short+"\n");
//$index=`gmatch $inputNode_name $destNode_name_Short`;
//if($index > 0){
if($inputNode_name_Short==$destNode_name_Short){
//$blendShapeName = $blendshapeRet_name;
print("$destNode_name= "+$destNode_name+" isHit!! "+"\n");
select -r $inputNode_name;
select -add $destNode_name;
copySkinWeights -noMirror -surfaceAssociation closestPoint -influenceAssociation closestJoint;
//copySkinWeights -noMirror -surfaceAssociation closestPoint -influenceAssociation closestJoint -sourceSkin $inputNode_name -destinationSkin $destNode_name;
$finded = 1;
}//if
}//for
if($finded==0){
$rejectArr[size($rejectArr)] = $destNode_name;
}//if
}//if
}//for
print("----rejected_list---start"+"\n");
print($rejectArr);
print("----rejected_list---end"+"\n");
select -r $FirstSelect ;
select -add $SecondSelect ;