0

そのため、配列を a に渡す必要があります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 clicked\n") ;
    global int $applyCurrentType ;
    $applyCurrentType = 1 ;
    select -cl ;
    select $selectedFace ;
    crTestScripts ;
}
4

2 に答える 2

0

proc createControllers(string $name[], int $position)配列を取る自動リグスクリプトで使用しました。Maya はうるさいので、mel を使用するときにグローバルという用語を使用することは避け、スクリプトに変更を加えるたびに再ハッシュ関数を使用します。

proc buildRig()
{
    string $rootNode[]=`ls -sl`;
    createControllers($rootNode, 0);    
} 

proc createControllers(string $name[], int $position)

私のために働いた。proc createControllersmy配列ではmy$name配列と同じ$rootNodeです。

これが役に立てば幸いです、頑張ってください!

于 2011-12-12T06:24:33.440 に答える
0

私の前の答えは間違っていました。

したがって、配列をprocに渡すには、それをグローバル変数として再定義する必要があり、 プロシージャ内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 には 2 つの利点があります。配列ls -flを平坦化し、複数のフィルターを使用できることです。-sm 34 -sm 31

または、最善の方法だと思います... (グローバル変数は好きではありません) 丸括弧内の引数には、変数宣言の通常の構文を使用するだけです:

グローバル proc proc_name( *args_here ){ somecode; 戻る; }

*引数:

文字列 $str、文字列 $ls_str[]、浮動小数点 $scaleX、浮動小数点 $scale[];.. ベクトル $vec など

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

前のリスト結果を使用$selectedFace:

hide_items($selectedFace);

おっと... Maya は顔を隠せないことを忘れていました xD

于 2013-02-20T12:09:11.873 に答える