(API) Get flag names from MArgList

36 views
Skip to first unread message

Michael Boon

unread,
Feb 16, 2017, 6:45:35 PM2/16/17
to Python Programming for Autodesk Maya


Hi all

Is there a list anywhere near as good as this one for asking C++ API questions?

I have a plugin that takes a bunch of flags and other arguments. From inside the plugin, I want to be able to print out which flags are in use. Since there are a lot of flags and they are in flux, I'd rather not write a long section of code that goes through them one at a time. Is there a way, using MArgList (or MSyntax, or MArgDatabase) to print out the _names_ of the flags that were specified?

My goal is to print out exactly what the user called (though I don't mind if short and long names are swapped).

Thanks!

Michael Boon

unread,
Feb 16, 2017, 9:34:39 PM2/16/17
to Python Programming for Autodesk Maya
Here's the answer.

To the first question, stackoverflow. Specifically http://stackoverflow.com/a/17797823/5184320

To the main question:
#include <string>
#include <sstream>
...
std
::stringstream stream;
stream
<< argList;
std
::string str = stream.str();
const char* chr = str.c_str();

Justin Israel

unread,
Feb 16, 2017, 10:53:02 PM2/16/17
to python_in...@googlegroups.com
On Fri, Feb 17, 2017 at 3:34 PM Michael Boon <boon...@gmail.com> wrote:
Here's the answer.

To the first question, stackoverflow. Specifically http://stackoverflow.com/a/17797823/5184320

To the main question:
#include <string>
#include <sstream>
...
std
::stringstream stream;
stream
<< argList;
std
::string str = stream.str();
const char* chr = str.c_str();



Cool, thanks for confirming that you figured this one out. You are welcome to ask C++ Maya API questions here. The title of the forum suggests we would only accept Python topics but the scope has grown from the original intent. People even ask Python questions unrelated to Maya.

Justin

 

On Friday, 17 February 2017 10:45:35 UTC+11, Michael Boon wrote:


Hi all

Is there a list anywhere near as good as this one for asking C++ API questions?

I have a plugin that takes a bunch of flags and other arguments. From inside the plugin, I want to be able to print out which flags are in use. Since there are a lot of flags and they are in flux, I'd rather not write a long section of code that goes through them one at a time. Is there a way, using MArgList (or MSyntax, or MArgDatabase) to print out the _names_ of the flags that were specified?

My goal is to print out exactly what the user called (though I don't mind if short and long names are swapped).

Thanks!

--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/8f7a7d9a-b823-4b35-936d-4e760168fec8%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages