snapVertexToGrid.mel Maya 2010?

Hi,

Im looking to move every selected vertex to it's nearest grid point in Maya i found this script does anybody knows if it would work with Maya 2010? i can't make it work myself

Thanks

// snapVertexToGrid.mel
// by Naughty (naughty_genepool@hotmail.com)
//
// This script simply moves every selected vertex to it's nearest grid point 
// (based on current grid settings).
//
// Usage:
//
// snapVertexToGrid;
// moves every selected vertex to it's nearest grid point
//
//
// goto:
// http://www.naughtynathan.supanet.com/mel.htm
// for more detailed explanations, pictures and even more MEL scripts...

global proc snapVertexToGrid()
{
float $gridSpace = grid -q -sp;
float $gridSubD = grid -q -d;
float $gridSize =($gridSpace/$gridSubD);
// print ("grid size: " + $gridSize + "\n");

string $selVerts[] = filterExpand -fullPath 1 -expand 1 -sm 31;
if(!size($selVerts)) error "No Vertices selected!\n";
for ($vertex in $selVerts)
{
float $xyzPos[] = xform -q -ws -a -t $vertex;
// print ("X position: " + $xyzPos[0] + "\n");
// print ("Y position: " + $xyzPos[1] + "\n");
// print ("Z position: " + $xyzPos[2] + "\n");

$xyzPos[0] = $gridSize * ( int( ( $xyzPos[0] + $gridSize / 2.0 * sign $xyzPos[0] ) / $gridSize ) );
$xyzPos[1] = $gridSize * ( int( ( $xyzPos[1] + $gridSize / 2.0 * sign $xyzPos[1] ) / $gridSize ) );
$xyzPos[2] = $gridSize * ( int( ( $xyzPos[2] + $gridSize / 2.0 * sign $xyzPos[2] ) / $gridSize ) );

xform -ws -a -t $xyzPos[0] $xyzPos[1] $xyzPos[2] $vertex;
}
}

The author of this script resides at cgsociety if you want to ask him. But i doubt it would be nesseccary. I guess you pasted the script into your Script Editor and executed it as it is? If so you only make maya familiar with the procedure, you do not execute the script this way. To execute it select your vertices and just type

snapVertexToGrid();

Hi, 

Thanks so much for your answer that made it work!!!