Home Technical Talk

Maya Grid Shortcut

admin
Offline / Send Message
System admin
Hey guys,

Does anyone happen to know add more lines to the grid in Maya (2011) without going to the Grid option box?

I'm watching the Gnomon's Environment Modeling for Games and the artist does it a couple of times while modeling.

Replies

  • haiddasalami
    Options
    Offline / Send Message
    haiddasalami polycounter lvl 14
    Hmm could bound a shortcut key to mel command like this:
    float $gridSpacing = 32;
    float $gridDivisions = 1;
    float $gridSize = 2048;
    grid -size $gridSize -spacing $gridSpacing -size $gridDivisions;
    

    $gridSize would be the length and width
    $gridSpacing would be grid lines every
    $gridDivisions is the divisions.
  • m4dcow
    Options
    Offline / Send Message
    m4dcow interpolator
    I have wondered if there was a set hot key too, but could never find it, so I wrote this script.

    The 1st snippet is to double the divisions.
    The 2nd snippet halves the divisions, if the division number is currently 1 (lowest it can go) I double the spacing instead.
    //Double grid divisions
    int $gDiv;
    $gDiv = `grid -query -divisions`;
    grid -divisions ($gDiv*2);
    
     
    //Halve grid divisions
    int $gDiv;
    $gDiv = `grid -query -divisions`;
    //Divisions can't go below 1, so I increase spacing
    if ($gDiv <= 1){
        int $gSpc;
        $gSpc = `grid -query -spacing`;
        grid -spacing ($gSpc*2);
    }
    else{
        grid -divisions ($gDiv*.5);
    }
    
  • System
    Options
    Offline / Send Message
    System admin
    whoa, thanks! These are really helpful.
    I have both of them on my custom shelf, works great.
  • Silver
    Options
    Offline / Send Message
    m4dcow, thanks!

    You can create HUD, to show the current divisions value of the grid?
  • haiddasalami
    Options
    Offline / Send Message
    haiddasalami polycounter lvl 14
    Silver wrote: »
    m4dcow, thanks!

    You can create HUD, to show the current divisions value of the grid?
    //Remove display if exists 
    headsUpDisplay -rem GridDisplay;
     
    //Procedure to grab values of grid
     
    global proc int gridSettings ()
    {
    $gridDivisions = `grid -query -divisions`;
    return $gridDivisions;
    }
     
    $block = `headsUpDisplay -nfb 0`; 
     
    headsUpDisplay -section 0
    -block $block
    -blockSize "small"
    -label "Current Divisions:"
    -labelFontSize "small"
    -command "gridSettings()"
    -attachToRefresh
    GridDisplay;
     
    

    Didnt even know you could do this :) Want to see if I can get it into the actual heads up Display box rather than creating one.

    EDIT: Added to underneath UVs. Will wrap this into a function probably later this evening so you can put it in your startup file.
  • haiddasalami
    Options
    Offline / Send Message
    haiddasalami polycounter lvl 14
    Just made the script into a mel file. Can download it here. If dropbox is blocked let me know will host somewhere else.

    Save that in Documents -> Maya -> Version -> Scripts

    Next add this to start up.

    If you have a custom user startup just append

    source GridHUD;

    If you do not have one check Documents -> Maya -> Version -> scripts if you do have one. If you do just append source GridHUD; to the next line. If you dont follow the steps below.

    1. Navigate to maya install directory
    2. Go to Scripts
    3. Copy userSetup.mel
    4. Paste in Documents -> Maya -> Version -> scripts
    5. Open with Notepad
    6. Append this to the next free line

    eval("source GridHUD.mel");

    Save and run :)

    Had to move the Grid Divisions to the next block as it was loading before the actual HUD stuff so taking their place. Still looking through the Startup stuff to see if I can find where they are declared :(
  • Silver
    Options
    Offline / Send Message
    haiddasalami, many thanks!
  • Visum
    Options
    Offline / Send Message
    Visum polycounter lvl 7
    I know this is old but could anybody help me to modify this so it adds divisions by 1 not doubles/halves it?
    I have maya set up to grid lines every 50cm and major evey 100cm so I end up with 12.5cm grids and etc using the above script and I don't know how to modify it/
Sign In or Register to comment.