Home Technical Talk

Script for changing grid size in Maya?

jordank95
polycounter lvl 8
Offline / Send Message
jordank95 polycounter lvl 8
Looking for a MEL script to change grid size in Maya by powers of 2. Its annoying to go through this manually every time I want to change the grid size when working on modular sets. Anyone know of one? Im pretty useless when it comes to programming it myself. 

Replies

  • rekab
    Options
    Offline / Send Message
    rekab polycounter lvl 8
  • rekab
    Options
    Offline / Send Message
    rekab polycounter lvl 8
    Here you go. -- Make two MEL shelf buttons.
    Then, here's the MEL code for shelf button 1:

    //turn off undo

    undoInfo -stateWithoutFlush false;

    //query current grid divisions

    int $gridDivs = `grid -q -divisions`;

    //calculate new divisions

    $gridDivs = $gridDivs * 2;

    //query current grid spacing

    int $gridSpacing = `grid -q -spacing`;

    //set new divisions

    grid -spacing $gridSpacing -divisions $gridDivs;

    //turn undo back on

    undoInfo -stateWithoutFlush true;


    Here's the MEL code for shelf button 2:


    //turn off undo

    undoInfo -stateWithoutFlush false;

    //query current grid divisions

    int $gridDivs = `grid -q -divisions`;

    //calculate new divisions

    $gridDivs = $gridDivs / 2;

    //query current grid spacing

    int $gridSpacing = `grid -q -spacing`;

    //set new divisions

    grid -spacing $gridSpacing -divisions $gridDivs;

    //turn undo back on

    undoInfo -stateWithoutFlush true;

  • jordank95
    Options
    Offline / Send Message
    jordank95 polycounter lvl 8
    @rekab Yes! This is perfect! This is why I love this community. Thanks a ton my friend. 
  • rekab
    Options
    Offline / Send Message
    rekab polycounter lvl 8
    jordank95 said:
    @rekab Yes! This is perfect! This is why I love this community. Thanks a ton my friend. 
    No prob -- Happy to help
Sign In or Register to comment.