2017-03-29 86 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();