Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/haskell/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ 使用Maya API类MArgList中的get函数时获取神秘的类型转换_C++_Api_Plugins_Maya - Fatal编程技术网

C++ 使用Maya API类MArgList中的get函数时获取神秘的类型转换

C++ 使用Maya API类MArgList中的get函数时获取神秘的类型转换,c++,api,plugins,maya,C++,Api,Plugins,Maya,我正在使用Maya API中的MArgList类检索在Maya命令行中输入的参数。根据类引用,MArgList::get应该能够将int或double作为其第二个参数,但它似乎只需要bool,因此在编译期间抛出转换错误。下面是代码部分和生成的错误。如果您对可能导致这种情况的原因有任何想法,我们将不胜感激。这段代码是直接从Maya插件开发教程中输入的,因此它为什么不工作是个谜 const int nPosts = 5; const double radius = 0.5; const double

我正在使用Maya API中的MArgList类检索在Maya命令行中输入的参数。根据类引用,MArgList::get应该能够将int或double作为其第二个参数,但它似乎只需要bool,因此在编译期间抛出转换错误。下面是代码部分和生成的错误。如果您对可能导致这种情况的原因有任何想法,我们将不胜感激。这段代码是直接从Maya插件开发教程中输入的,因此它为什么不工作是个谜

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 ==========

如果要从
get
函数中获取新值,则不能使用目标变量
const

试一试

另外,您不应该为每个调用声明一个新的
索引
变量。只需声明一次并重用它

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