所以我需要传递一个数组到global procedure
,但像往常一样,我必须重新定义它。我知道这是一个新手问题,但是数组可以作为过程传递吗?如果没有,是否可以将其设置为全局并插入到过程中。
$selectedFace = `ls -selection` ;
global proc crTestScripts($selectedFace) {
print ("OMG aren't lists of things awesome?!" + $selectedFace) ;
}
或
$selectedFace = `ls -selection` ;
global array? $selectedFace ;
global proc crTestScripts() {
global array? $selectedFace ;
print ("OMG aren't lists of things awesome?!" + $selectedFace) ;
}
我传入了这个字符串,我仍然得到这个错误:
Error: Wrong number of arguments on call to applyCurrentType
下面是一个示例代码:
string $selectedFace[] = `ls -sl` ;
global proc applyCurrentType (string $selectedFace[]) {
print("Apply Current Type button clickedn") ;
global int $applyCurrentType ;
$applyCurrentType = 1 ;
select -cl ;
select $selectedFace ;
crTestScripts ;
}
我使用proc createControllers(string $name[], int $position)
在一个自动钻机脚本,这是采取一个数组。当使用mel时,我远离使用术语全局,因为maya是挑剔的,只要我对脚本进行更改就使用rehash函数;
proc buildRig()
{
string $rootNode[]=`ls -sl`;
createControllers($rootNode, 0);
}
proc createControllers(string $name[], int $position)
对我有用。在proc createControllers
中,我的$name
数组等于我的$rootNode
数组。
希望这有帮助,祝你好运!
我之前的答案是错误的。
所以传递数组到进程你需要重新定义它为全局变量,string $selectedFace[];
将变成global string $selectedFace[];
内部程序。例如:
string $selectedFace[] = filterExpand("-sm", 34, `ls-selection`);
global proc crTestScripts(){
global string $selectedFace[];
print $selectedFace;
}
crTestScripts();
// result: body_skinPrx_finalSkin.f[103]
filterExpand提供了两个好处,它使数组ls -fl
平坦化,并且可以使用多个过滤器-sm 34 -sm 31
或者,我认为最好的方法是…(不喜欢全局变量)对于圆括号中的args,只需使用正常的变量声明语法:
全局proc_name(*args_here){somecode;返回;}
* args:
string $str, string $ls_str[], float $scaleX, float $scale[];向量$vec等
global proc hide_items(string $items[]){
hide $items;
}
using previous list result $selectedFace
:
hide_items($selectedFace);
哦…我忘了maya不能隐藏人脸xD