Go to: Synopsis. Flags. Return value. Python examples.
grid([default=boolean], [displayAxes=boolean], [displayAxesBold=boolean], [displayDivisionLines=boolean], [displayGridLines=boolean], [displayOrthographicLabels=boolean], [displayPerspectiveLabels=boolean], [divisions=int], [orthographicLabelPosition=string], [perspectiveLabelPosition=string], [reset=boolean], [size=linear], [spacing=linear], [style=int], [toggle=boolean])
Note: Strings representing object names and arguments must be separated by commas. This is not depicted in the synopsis.
grid is undoable, queryable, and editable.
This command changes the size and spacing of lines on the ground
plane displayed in the perspective and orthographic views.
This command lets you reset the ground plane, change its size
and grid line spacing, grid subdivisions and display options.
default, displayAxes, displayAxesBold, displayDivisionLines, displayGridLines, displayOrthographicLabels, displayPerspectiveLabels, divisions, orthographicLabelPosition, perspectiveLabelPosition, reset, size, spacing, style, toggle
| Long name (short name) |
[argument types] |
Properties |
toggle(tgl)
|
boolean
|

|
|
Turns the ground plane display off in all windows, including
orthographic windows. Default is true.
In query mode, this flag needs a value.
|
|
reset(r)
|
boolean
|
|
|
Resets the ground plane to its default values
|
|
default(df)
|
boolean
|

|
|
Used to specify/query default values.
In query mode, this flag needs a value.
|
|
spacing(sp)
|
linear
|

|
|
Sets the spacing between major grid lines in linear units.
The default is 5 units.
In query mode, this flag needs a value.
|
|
size(s)
|
linear
|

|
|
Sets the size of the grid in linear units. The default is
12 units.
In query mode, this flag needs a value.
|
|
divisions(d)
|
int
|

|
|
Sets the number of subdivisions between major grid lines.
The default is 5. If the spacing is 5 units, setting
divisions to 5 will cause division lines to appear 1 unit
apart.
In query mode, this flag needs a value.
|
|
displayAxes(da)
|
boolean
|

|
|
Specify true to display the grid axes.
In query mode, this flag needs a value.
|
|
displayGridLines(dgl)
|
boolean
|

|
|
Specify true to display the grid lines.
In query mode, this flag needs a value.
|
|
displayDivisionLines(ddl)
|
boolean
|

|
|
Specify true to display the subdivision lines between
grid lines.
In query mode, this flag needs a value.
|
|
displayPerspectiveLabels(dpl)
|
boolean
|

|
|
Specify true to display the grid line numeric labels in
the perspective view.
In query mode, this flag needs a value.
|
|
displayOrthographicLabels(dol)
|
boolean
|

|
|
Specify true to display the grid line numeric labels in
the orthographic views.
In query mode, this flag needs a value.
|
|
displayAxesBold(dab)
|
boolean
|

|
|
Specify true to accent the grid axes by drawing them with a
thicker line.
In query mode, this flag needs a value.
|
|
perspectiveLabelPosition(plp)
|
string
|

|
|
The position of the grid's numeric labels in perspective
views. Valid values are "axis" and "edge".
In query mode, this flag needs a value.
|
|
orthographicLabelPosition(olp)
|
string
|

|
|
The position of the grid's numeric labels in orthographic
views. Valid values are "axis" and "edge".
In query mode, this flag needs a value.
|
|
style(st)
|
int
|

|
|
This flag is obsolete and should not be used.
In query mode, this flag needs a value.
|
|
Flag can appear in Create mode of command
|
Flag can appear in Edit mode of command
|
Flag can appear in Query mode of command
|
Flag can have multiple arguments, passed either as a tuple or a list.
|
Return value depends on queried flag.
import maya.cmds as cmds
#To toggle the grid display of the grid (in all views):
currState = cmds.grid( toggle=True, q=True )
cmds.grid( toggle=(currState == 0) )
# To reset the grid to default values:
cmds.grid( reset=True )
# To change the grid spacing and subdivisions:
cmds.grid( spacing=10, d=10 )
# To set the defaults for inches
cmds.grid( default=True, spacing='1in', size='1ft', divisions=4 )
# To change the size of the grid to 20x20, extending 10 units
# in each direction:
cmds.grid( spacing=10 )
# To query the current size of the grid:
# returns a size in the current linear unit.
cmds.grid( query=True, size=True )
# A typical grid would be a grid size of 20x20, with
# major grid lines every 5 units, with 5 divisions between
# major grid lines. This be done with the following command.
cmds.grid( size='10cm', sp='5.0cm', d=5 )
# Turn on numeric grid labels.
#
cmds.grid( displayPerspectiveLabels=True )
# Display grid labels along the axes.
#
cmds.grid( perspectiveLabelPosition='axis' )