Home Technical Talk

[MAYA] MEL script to switch vertex color tool option

polycounter lvl 4
Offline / Send Message
Old Wither polycounter lvl 4
I do a lot of vertex painting in my workflow, and I’m trying to set up hotkeys for common actions. I’ve got pretty much everything set except one thing, which I can’t seem to figure out: switching between painting vertex | vertex face | face. There are three radio buttons in the Paint Vertex Colors tool settings to choose these options. Looking in the Script Editor (with Echo All Commands checked), when I choose any of the three options I see this:

artAttrPaintVertexOrFace artAttrPaintVertexCtx;
artPaintVertexInitPaintableAttr;
// Result: 0 // 
artAttrPaintVertexOrFace artAttrPaintVertexCtx;
artPaintVertexInitPaintableAttr;
// Result: 0 // 

I get the same thing when I choose vertex, vertex face, or face. I’d like to be able to save out a line of MEL to a hotkey for switching between these paint options, but I can’t quite figure it out. Not sure if this is helpful, but:

Replies

  • Treidge
    Options
    Offline / Send Message
    Treidge polycounter lvl 11
    You should start by checking the procedure defined in Line 30-74 in your [Maya Install Directory]\scripts\others\artAttrColorPerVertexCallback.mel

    Really quick investigation got me this commands to set the paint mode to vertex, vertex face and face respectively:

    artAttrPaintVertexCtx -e -paintComponent 1 `currentCtx`;
    artAttrPaintVertexCtx -e -paintComponent 2 `currentCtx`;
    artAttrPaintVertexCtx -e -paintComponent 3 `currentCtx`;
    If you wish to use a "smart" hotkey, you can query the current state of the radiobutton (and paint mode) with -query flag and following command. The result will be Integer, i.e. a number: 1, 2 or 3.
    artAttrPaintVertexCtx -q -paintComponent `currentCtx`;
    Note that radiobuttons in Tool Settings will not update automatically after executing either one of this — probably because the command itself isn't complete. You may want to try and complement it with missing parts if you will figure them out. However, the mode will change and radiobuttons will update their status after the first stroke made in the new mode.  :)

    Hope that helps.

  • Old Wither
    Options
    Offline / Send Message
    Old Wither polycounter lvl 4
    Oh, that looks fantastic!
    Yep, a quick test shows that it works like a charm. This is going to make my work much easier. Thanks so much :)
Sign In or Register to comment.