0

How to get names from an array and cast them to another array in mel and also replace part of a name in the process? Like substituting "_L" with "_R" in their names

Thank you

1 Answers1

1
string $array_1[] = {"box_1_L", "box_2_L"};
string $array_2[] = {"sphere_1", "sphere_2"};

//append
appendStringArray($array_1, $array_2, (size($array_2)) );
print $array_1;

//rename in loop
for($i=0;$i<size($array_1);++$i){
        $array_1[$i] = `substitute "_L" $array_1[$i] "_R"`;}
print $array_1;

If I get you right

SAF
  • 309
  • 2
  • 13
  • this is useful for what I am doing. thank you. But what I meant was, for this example, change the names in the second array for the ones in the first array and change the L for R, so sphere_1 would be box_1_R, sphere_2 would be box_2_R. Thanks – Orkhan Ashrafov Mar 27 '16 at 11:14
  • $array_2 = $array_1 and substitute? – SAF Mar 27 '16 at 12:46
  • well yes. but is doing $array_2 = $array_1 applies names of the objects in the first array to the objects in the second one? sorry I'm a bit new to this. I would have thought after doing $array_2 = $array_1 , doing anything on $array_2 would change objects in $array_1. – Orkhan Ashrafov Mar 27 '16 at 13:14
  • I advise you to read Complete Maya Programming vol 1 ISBN-10: 1558608354 – SAF Mar 27 '16 at 13:32
  • @SAF I do not suggest reading complete maya programming, your much better of skim reading the help cover to cover in terms of time and money used. Yes i have the book and there were only 3 pages worth reading in it. – joojaa Apr 01 '16 at 06:31