2017-03-29 80 views
1

如何將帶有字符串數組參數的命令傳遞給MEL中的evalEcho?下面的代碼不起作用(只是一個例子),$list必須被聲明爲可以工作,但這是在createList中完成的。Maya MEL腳本將字符串數組參數傳遞給evalEcho

global proc string[] returnList(string $list[]) { 
    return $list; 
} 

global proc createList() { 
    string $list[]; 

    $list[0] = "Hello"; 
    $list[1] = "World"; 

    evalEcho "returnList $list"; 
} 

createList(); 

終端:

// Error: Line 11.17: "$list" is an undeclared variable. //

出於某種原因,下面的代碼按預期工作:

global proc string[] returnList(string $list[]) { 
    return $list; 
} 

string $list[]; 

$list[0] = "Hello"; 
$list[1] = "World"; 

evalEcho "returnList $list"; 

回答

0

此代碼應該工作您預期的方式:

global proc string[] returnList(string $list[]) { 
    return $list; 
} 

global proc createList() { 
    string $list[]; 
    $list = stringToStringArray("Hello, World!", " "); 

    evalEcho("\n" + "//" + " " + $list[0] + " " + $list[1] + " "); 
} 

createList(); 

enter image description here

1

或者把它們放在裏面太....

global proc string[] returnList(string $list[]) { 
    return $list; 
} 

global proc createList() { 
    evalEcho "string $list[]"; 

    evalEcho "$list[0] = \"Hello\""; 
    evalEcho "$list[1] = \"World\""; 

    evalEcho "returnList $list"; 
} 

createList();