24 January 2011

Mel scripting - toggle Snap Component Spacing

Hello world!

So right, I decided to start a new project today and create some little props to get me back into the whole workflow. I then thought of a little script to toggle on/off the snap component spacing - it's annoying to keep going into the Move tool settings!

So here you have it:

//here we're finding out what the current value of the snap component is (0 = false and 1 = true)
int $snapResult = `manipMoveContext -q -snapComponentsRelative Move`;


//run this batch of code if the value is false (0)
if ($snapResult == 0)
    {
         //setting the component spacing to true
         manipMoveContext -e -snapComponentsRelative true Move;
         print ("Component spacing: ON\n");
    }
         //run this batch of code if the value is anything other than 0, in this case - 1
         else
             {
                  manipMoveContext -e -snapComponentsRelative false Move;
                  print ("Component spacing: OFF\n");
              }


We could have done this much easier by using the "Double Click" option in the Shelf editor but where's the fun in that? :P


2 comments:

  1. Hey this script was a HUGE help to me, I just assigned it to a hotkey and now I am in maya bliss, thanks so much for posting this I truly appreciate it, and now i'm gonna follow your blog :P

    ReplyDelete
  2. This comment has been removed by the author.

    ReplyDelete