I wrote an MEL script in Maya. So I want to select a joint, then run the MEL script and it selects that joint and all its children. I very new to MEL, So with running the code, it throws a bunch of errors. Can you help me reduce error or better to get rid of all of them?
The Script:
string $joints[];
string $current[] = 'ls -selection';
proc selectJoints (){
if ('searchJoints($joints)' == 0){
$joints['size($joints)'] = $current[0];
pickWalk -d down;
$current[0] = 'ls -sl';
selectJoints();
}
else{
pickWalk -d right;
$current[0] = 'ls -sl';
if('searchJoints($joints)' == 0){
selectJoints();
}
else{
pickWalk -d up;
$current[0] = 'ls -sl';
if($current[0] == $joints[0]){
selectJoints();
}
}
}
return;
}
select ($Joints);
proc int searchJoints (string $jns[]){
int $result = 0;
for ($joint in $jns[]){
if ($current[0] == $joint){
return 1;
}
}
return 0;
}
So, I know your question is about MEL, and I am sorry for not being able to help you with that BUT i think i can help you with python and pymel.
Try this code in a Python tab in the script editor:
I am not sure why to use MEL, I started directly with pymel and it seems more powerful. Could you tell me why MEL?...I think I might be missing out on something. Anyway, I think this short code does the trick. Good luck! Be aware that there are no fail safes there. so, make sure you select ONE joint to run before running the script.