2011-12-12 2 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) ; 
} 

내가이 문자열을 전달 그리고 난이 오류가 계속 얻을 :

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 ; 
} 
:

여기 Error: Wrong number of arguments on call to applyCurrentType

코드의 샘플입니다

+0

내가 알고있는 조각에서 늦게 Tad, 그러나 t 그는 아마도 당신이 당신의 applyCurrentType() 함수를 호출하는 방법 때문일 것입니다. 당신이 그 코드를 긁어 낼 수 있다면 아마 더 많은 도움을 줄 수 있을까요? (호출은 다음과 같아야합니다 :'applyCurrentType ($ selectedFace)'methinks) – tanantish

답변

0

어레이를 취하는 자동 장비 스크립트에서 sed proc createControllers(string $name[], int $position). 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는 [] =의'1! -sl' ; 전역 proc applyCurrentType (문자열 $ selectedFace []) { \t 인쇄 ("현재 유형 적용 버튼을 클릭하십시오. \ n"); \t 글로벌 int $ applyCurrentType; \t $ applyCurrentType = 1; \t select -cl; \t select $ selectedFace; \t crTestScripts; } –

0

내 이전 대답이 잘못되었습니다.

정도로 string $selectedFace[]; 프로 내부 global string $selectedFace[]; 해질 것이다 u는 전역 변수로서 다시 정의해야 PROC 배열로 통과한다. 예 :

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에 대한 변수 선언의 일반적인 구문을 사용하면됩니다.

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

* 인수 :

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 잊었다
관련 문제