0

I made a joint chain for a leg and named each joint, "thigh", "knee", "ankle", "ball", and "toe." I want this code to duplicate the chain and then add "_FK" to the end of each name. Right now it will only change the first name correctly, and then the rest don't change. It gives the error message "Error: No object matches name." What is preventing the for loop from working? This code works perfectly when I take out the duplication line.

duplicate -rr;

string $currentSelection[] = `ls -sl -fl`; //get name of selected objects//

int $theArraySize = size($currentSelection);
int $counter = 0;
string $newName = "";

for (  $i = 0 ; $i < $theArraySize; $i++ )
{
   $newName = $currentSelection[$i] + "_FK" ;
   rename $currentSelection[$i] $newName;
   $counter += 1;
}
  • `ls -sl -fl -l`; did you tried long flag ? – Achayan Dec 04 '15 at 22:08
  • I eventually figured it out. I had to rename the children when I duplicate them. I also needed to get the original names to use when I rename them. duplicate -rr -rc; – Mariah Kay Seagle Dec 04 '15 at 22:12
  • 1
    The old pro cheat is to get the long names with the -l flag, reverse the list, and do your renames from the longest to the shortest -- the long path names will always sort after short ones, so you can work from the depths of the hierarchy up to the top. This is much easier in python, there's a good example here: http://stackoverflow.com/questions/32597668/select-all-locators-in-maya-and-rename-them-all-at-once-in-python/32601658#32601658 – theodox Dec 07 '15 at 17:55

0 Answers0