MPxContextCommand - flag for RGB value?

MPxContextCommand - flag for RGB value?

RFlannery1
Collaborator Collaborator
1,041 Views
6 Replies
Message 1 of 7

MPxContextCommand - flag for RGB value?

RFlannery1
Collaborator
Collaborator

I am writing a plugin for a new interactive tool.  One of the options that the user can set is a color.  So I would like to have a -rgb flag.  Now I'm at the part where I'm fleshing out the "doQueryFlags" function in my class, which derives from MPxContextCommand.  The problem I've run into is that the "setResult" function only has overrides for bool, int, double, and MString.  So it looks like there isn't a way to query a flag with an array of values (like a color).

 

I was about to give up and just make separate -r, -g, and -b flags when I came across something interesting.  One of Maya's built in commands is "artAttrPaintVertexCtx".  It has a -colorRGBValue flag that returns three floats.  It certainly looks like something derived from MPxContextCommand.  But I can't figure out how they got that flag to work.  Is there something I'm missing?

0 Likes
Accepted solutions (1)
1,042 Views
6 Replies
Replies (6)
Message 2 of 7

cheng_xi_li
Autodesk Support
Autodesk Support

Hi,

 

Have you tried with appendToResult?

 

e.g. 

 

appendToResult(r);
appendToResult(g);
appendToResult(b);

 

 

Yours,

Li

0 Likes
Message 3 of 7

RFlannery1
Collaborator
Collaborator

Unfortunately I don't see an "appendToResult" function for the MPxContextCommand class.

0 Likes
Message 4 of 7

cheng_xi_li
Autodesk Support
Autodesk Support
Accepted solution
Hi,

Yes, you are right. I was looking into the internal code for the command you’ve mentioned. I checked it again, it was implemented in a different way with internal classes. I am afraid there isn’t a way to return multiple values like MPxCommand with MPxContextCommand.
Sorry for the mistake.

Yours,
Li
0 Likes
Message 5 of 7

RFlannery1
Collaborator
Collaborator

Thanks for your reply.  I was wondering if it might have been doing something special in Maya's internal code.  But I have no way of knowing that since I don't have Maya's code. 😁 Thank you for confirming that.  Now I can be confident that there is no way to do it and that I am not just missing something.  👍  Onward with my -r, -g, and -b flags!

0 Likes
Message 6 of 7

cheng_xi_li
Autodesk Support
Autodesk Support

BTW: I just remembered that helixTool sample creates a MPxToolCommand with the MPxContextCommand. The tool command does the actual helix creation and the context handles interactive part. The MPxToolCommand should be able to use appendToResult. I am not sure if your usage was similar to the sample.  Hope it helps.

Yours,
Li

0 Likes
Message 7 of 7

RFlannery1
Collaborator
Collaborator

My usage is somewhat similar.  In fact, I have been using the helixTool and grabUV examples as my primary sources for how to make everything work.  Right now I'm working on setting and retrieving the tool options through the Tool Property sheet.  All the examples I've seen (for example "helixProperties.mel" and "helixValues.mel") call the context command to set and get the values.  So that's why I'm trying to do it that way.

 

Thanks for the suggestion, though.  I really appreciate your help.

0 Likes