heya,
got a problem with multiuse arguments and python. google only leads to other posts similar
to mine none of which got an answer.

i'm writting a custom command in C++, but intending to call that from maya in python.
i need to define a multiuse argument for it (array of strings).
i've got command up and running, but the problem is... MEL call works fine, while Python won't. my code is really based just on whatever is posted as a correct example of reading
multi-use arguments (including the example in maya's API)

software: maya 2008, visual studio 2008.

i call command as:

MEL: ngTestCmd -s "persp" -s "top"  (outputs "persp" and "top" correctly)
Python: cmds.ngTestCmd(s=["persp","top"]) (fails trying to print first element)


i define command syntax as:

   MSyntax syntax;
   syntax.addFlag(TEST_FLAG,"strings",MSyntax::kString);
   syntax.makeFlagMultiUse(TEST_FLAG);
   syntax.enableQuery( false );
   syntax.enableEdit( false );
   return syntax;

i read args like this (CHECK_STATUS macro fires statusException if status is not "success"):
   try {
       MStatus status;
       MArgDatabase argDb(this->syntax(),args,&status);
       CHECK_STATUS("failed to create arg db");

       uint numUses = argDb.numberOfFlagUses(TEST_FLAG);
       for (uint i=0;i<numUses;i++){
           MArgList selList;
           status = argDb.getFlagArgumentList(TEST_FLAG,i,selList);
           CHECK_STATUS("failed to get sel list");

           // asString fails when command call is made from python
           MGlobal::displayInfo(selList.asString(0,&status));
           CHECK_STATUS("failed to get string from sel list");

       }
   }
   catch (StatusException e){
       MGlobal::displayError(e.getStatus().errorString());
       return e.getStatus();
   }

in both python and MEL calls numberOfFlagUses return 2, which is correct. however,
python calls always result in status check failure after selList.asString()

help! :)

--
viktoras
www.neglostyti.com

--
http://groups.google.com/group/python_inside_maya

Reply via email to