2012-07-21 1 views
0

Maya API의 MArgList 클래스를 사용하여 Maya 명령 줄에 입력 된 인수를 검색합니다. 클래스 참조에 따르면 MArgList :: get은 int 또는 double을 두 번째 인수로 취할 수 있어야하지만 bool 만 예상하고 있으므로 컴파일하는 동안 변환 오류가 발생합니다. 다음은 코드 섹션과 생성 된 오류입니다. 이 문제의 원인에 대한 생각은 많이 감사 할 것입니다. 이 코드는 Maya 플러그인 개발 자습서에서 바로 입력되었으므로 작동하지 않는 이유는 수수께끼입니다. 당신이 get 함수에서 새 값을 얻을려고하는 경우에Maya API 클래스에서 get 함수를 사용할 때 신비한 형식 변환 받기 MArgList

const int nPosts = 5; 
const double radius = 0.5; 
const double height = 5.0; 

unsigned index; 
index = args.flagIndex("n", "number"); 
if(MArgList::kInvalidArgIndex != index) 
    args.get(index + 1, nPosts); 

unsigned index; 
index = args.flagIndex("r", "radius"); 
if(MArgList::kInvalidArgIndex != index) 
    args.get(index + 1, radius); 

unsigned index; 
index = args.flagIndex("h", "height"); 
if(MArgList::kInvalidArgIndex != index) 
    args.get(index + 1, height); 


1>Posts1Cmd.cpp(37): error C2664: 'MStatus MArgList::get(unsigned int,bool &) const' :    cannot convert parameter 2 from 'const int' to 'bool &' 
1>Posts1Cmd.cpp(39): error C2086: 'unsigned int index' : redefinition 
1>   Posts1Cmd.cpp(34) : see declaration of 'index' 
1>Posts1Cmd.cpp(42): error C2664: 'MStatus MArgList::get(unsigned int,bool &) const' : cannot convert parameter 2 from 'const double' to 'bool &' 
1>Posts1Cmd.cpp(44): error C2086: 'unsigned int index' : redefinition 
1>   Posts1Cmd.cpp(34) : see declaration of 'index' 
1>Posts1Cmd.cpp(47): error C2664: 'MStatus MArgList::get(unsigned int,bool &) const' : cannot convert parameter 2 from 'const double' to 'bool &' 
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ========== 

답변

1

, 당신은 목표 변수를 const 수 없습니다.

또한, 각 호출에 대해 새로운 index 변수를 선언하지 않아야

int nPosts = 5; 
double radius = 0.5; 
double height = 5.0; 

을보십시오. 한번 선언하고 다시 사용하십시오.