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
    Options
    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`.

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

    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`.

    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;
    }
    else if ($SlideStatus == "surface") { dR_DoCmd("slideOff"); 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.