2011-12-12 68 views
0

所以我需要将数组传递到global procedure,但像往常一样,我必须重新定义它。我知道这是一个noobie问题,但可以将数组作为过程传入?如果不是,它是否可以成为全球性的并插入到程序中。将数组传递到全局过程

$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 clicked\n") ; 
    global int $applyCurrentType ; 
    $applyCurrentType = 1 ; 
    select -cl ; 
    select $selectedFace ; 
    crTestScripts ; 
} 
+0

我知道这件作品迟到了,但是t他得到的错误可能是由于你如何调用你的applyCurrentType()函数。如果你可以从头开始,我们可能会帮助更多? (该调用应该看起来像:'applyCurrentType($ selectedFace)'methinks) – tanantish

回答

0

我ü sed 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阵列。

希望能帮到你,祝你好运!

+0

我很感激帮助!我以为我疯了,我的意思是当然一个数组可以通过一个程序!但它仍然不适合我。 我传递INT这个字符串,我仍然得到这个错误: 错误:数量上调用的参数错误的applyCurrentType 这里是代码的样本: 串$ selectedFace [] ='LS -sl' ; global proc applyCurrentType(string $ selectedFace []){ \t print(“Apply Current Type Type buttoned clicked \ n”); \t global int $ applyCurrentType; \t $ applyCurrentType = 1; \t select -cl; \t select $ selectedFace; \t crTestScripts; } –

0

我以前的答案是错的。

所以要通过阵列分成PROC u需要重新定义它为全局变量, 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,和u可以使用多种过滤器-sm 34 -sm 31

或者,我认为最好的办法... (我不喜欢全局变量) 只需在圆括号中使用变量声明的正常语法来表示参数:

global proc proc_name(*args_here){ somecode; return; }

* ARGS:

string $str, string $ls_str[], float $scaleX, float $scale[];.. vector $vec etc.

global proc hide_items(string $items[]){ 
    hide $items; 
} 

使用前面的列表结果$selectedFace

hide_items($selectedFace);

哎呀......我忘了玛雅无法隐藏的面孔由xD