Home Coding, Scripting, Shaders

Mel Script to Toggle Edge Constraint

polycounter
Offline / Send Message
Justo polycounter
I have no idea how to check the current state the contraints are in, so as to make some simple if commands, and assign this script to a hotkey. Just in case, I'm talking about Maya 2016's new edge constraint feature found in the tool panel (I think they were in the modeling toolkit in previous versions, but broken).

I know the key lines here are "manipScaleSetXformConstraint none;" and "manipScaleSetXformConstraint edge;" to set the edges...

Could anyone provide any help or point me in the right direction?  


Replies

  • Treidge
    Offline / Send Message
    Treidge polycounter lvl 11
    I've made this script to toggle between Slide Edge, Slide Surface and Off states consequentially with a single hotkey. Feel free to modify it to suit your needs or to make your own from a scratch. The command you were looking for is `xformConstraint -query -type`.

    1. string $SlideStatus = `xformConstraint -query -type`;

    2. if ($SlideStatus == "none") {
    3. dR_DoCmd("slideEdge");
      inViewMessage -smg "Slide Edge is On" -pos topCenter -bkc 0x00000000 -fade;
      }

    4. else if ($SlideStatus == "edge") {
    5. dR_DoCmd("slideSurface");
    6. inViewMessage -smg "Slide Surface is On" -pos topCenter -bkc 0x00000000 -fade;
      }

    7. else if ($SlideStatus == "surface") {
    8. dR_DoCmd("slideOff");
    9. inViewMessage -smg "Slide Transform is Off" -pos topCenter -bkc 0x00000000 -fade;
      }
  • Justo
    Offline / Send Message
    Justo polycounter
    B-bless you Treidge!! Have a great Sunday! You are the man! Thanks Sergey! 
  • Treidge
    Offline / Send Message
    Treidge polycounter lvl 11
    You're welcome :)
  • jayantbhatt007
    Offline / Send Message
    jayantbhatt007 polycounter lvl 8

    Treidge said:
    I've made this script to toggle between Slide Edge, Slide Surface and Off states consequentially with a single hotkey. Feel free to modify it to suit your needs or to make your own from a scratch. The command you were looking for is `xformConstraint -query -type`.

    1. string $SlideStatus = `xformConstraint -query -type`;

    2. if ($SlideStatus == "none") {
    3. dR_DoCmd("slideEdge");
      inViewMessage -smg "Slide Edge is On" -pos topCenter -bkc 0x00000000 -fade;
      }

    4. else if ($SlideStatus == "edge") {
    5. dR_DoCmd("slideSurface");
    6. inViewMessage -smg "Slide Surface is On" -pos topCenter -bkc 0x00000000 -fade;
      }

    7. else if ($SlideStatus == "surface") {
    8. dR_DoCmd("slideOff");
    9. inViewMessage -smg "Slide Transform is Off" -pos topCenter -bkc 0x00000000 -fade;
      }
    I removed slide constraint after this script is not working why  ( I don't use that)


    string $SlideStatus = `xformConstraint -query -type`;

    if ($SlideStatus == "none") {
    dR_DoCmd("slideEdge");
    inViewMessage -smg "Slide Edge is On" -pos topCenter -bkc 0x00000000 -fade;
    }

    else if ($SlideStatus == "edge") {
    dR_DoCmd("slideSurface");
    inViewMessage -smg "Slide Surface is On" -pos topCenter -bkc 0x00000000 -fade;
    }

Sign In or Register to comment.