MAXScript Tools and Interaction with 3ds Max > Interacting with the 3ds Max User Interface > Viewports >

# Viewport Grids

The following methods control the display and spacing of grid lines in the viewports.

    getGridSpacing()

Returns the spacing between grid lines in units.

    SetGridSpacing <float>

Sets home grid spacing. This corresponds to the Grid and Snap Settings dialog, Home Grid tab. The value is clamped to a minimum value of 0.001.

Available in 3ds Max 2008 and higher. Previously available in Avguard Extensions.

    getGridMajorLines()

Returns the number of grid lines between major grid lines.

    SetGridMajorLines <int>

Sets home grid major grid lines. This corresponds to the Grid and Snap Settings dialog, Home Grid tab. The value is clamped to a minimum value of 2.

Available in 3ds Max 2008 and higher. Previously available in Avguard Extensions.

The following 3ds Max system global variable is associated with the Viewport grids:

    activeGrid

Contains the currently active grid. If the home grid is active, returns the value undefined . You can assign a grid node object to this variable to make it the currently active grid.

You can also return to the home grid by setting activegrid = undefined .