Home Technical Talk

[Maya] Need help with toggle script for Bevel tool

polycounter lvl 9
Offline / Send Message
Bodizzz polycounter lvl 9
Hello!
I decided to create script to toggle between Bevel parameters. It should work like this: you press a hotkey and it launch Bevel tool, then, when the tool is active, you can press the same hotkey and toggle between parameteres like fraction, segment, chamfer, etc. I wrote some code as you can see on the GIF below, but i'm new to MEL, so i dont really know how to make script run with a one hotkey. I know that i should add a proc but i dont know how to do it properly and get errors every time. Maybe someone with good scripting skills can help me with that. 

I will include current code here.

if(!`dragAttrContext -ex "attrDrag"`)
    dragAttrContext "attrDrag";
string $toggle[];
int $cycle;

dragAttrContext -e -r "attrDrag";
setToolTo "attrDrag";

$toggle = `polyBevel3 -oaf 1 -fp 0 -o 0 -f 0.5 -sg 1 -d 1 -m 0 -ma 0 -c 1 -at 180 -sn 1 -mv 1 -mvt 0 -sa 30 -ch 1`;

if(`currentCtx` != "attrDrag")
    $cycle= 0;  
   switch($cycle){
        case 0:
            dragAttrContext -e -ct ($toggle[0] + ".f") "attrDrag";
            break;
        case 1:
            dragAttrContext -e -ct ($toggle[0] + ".sg") "attrDrag";
            break;
        case 2:
            dragAttrContext -e -ct ($toggle[0] + ".c") "attrDrag";
            break;    
        default:
            dragAttrContext -e -ct ($toggle[0] + ".f") "attrDrag";
            $cycle= 0;
            break;
    }
   $cycle++;

   
Thanks!

Replies

  • Fwap
    Offline / Send Message
    Fwap polycounter lvl 13
    Theres a modifier flag with draggercontext that lets you query if certain modifiers are being pressed.
    The documentation will say between ctrl and alt, but from what i've experienced, its actually shift and ctrl, i think alt conflicts with other built in context tools, like marking menus.

    you could have each method in a different function and use modifiers to toggle between them, without needing to switch tools.
  • sadpunk
    Offline / Send Message
    sadpunk polycounter lvl 8
    Did you ever get any further with this? I just Googled for this exact thing as I was getting fed up of clicking on the param I want to edit. Your sudo tool looks perfect. Good luck. 
  • Fansub
    Offline / Send Message
    Fansub sublime tool
    I wrote a tool that allows you to map any set of attributes on any Maya nodes to this workflow a few years ago; just tested it again it seems to be working in 2019. Will see if I have enough time to inspect it later this month and share it with y'all :)



  • romix
    Offline / Send Message
    romix polycounter lvl 5
    Yep, it will be very helpful! And if you can do it in a "fancy" way like the "SpeedFlow " addon for Blender. I mean with all heads up info and such

    UPD: also there a dr_beveltool in modeling toolkit in Maya, which allows you to add bevel on left click and controls the number of segments on ctrl+shift+LMM. But it works very strangely - after adding this bevel, I can't add more. Even the Script Editor not showing that command
  • Maddog4america
    Offline / Send Message
    Maddog4america polycounter lvl 5
    Bodizzz  Couldnt you just hotkey the last part?  You could also replace the whole bevel command in the context menu with yours as well.      Might be a simple fix for the time being. 
  • CybranM
    Offline / Send Message
    CybranM interpolator
    @Fansub
    Any update on the tool script? Looks fantastic
Sign In or Register to comment.