Go to: Synopsis. Return value. Flags. Python examples.
objectCenter(
object
, [gl=boolean], [local=boolean], [x=boolean], [y=boolean], [z=boolean])
Note: Strings representing object names and arguments must be separated by commas. This is not depicted in the synopsis.
objectCenter is undoable, NOT queryable, and NOT editable.
This command returns the coordinates of the center of the bounding box
of the specified object. If one coordinate only is specified, it will
be returned as a float. If no coordinates are specified, an array of
floats is returned, containing x, y, and z. If you specify multiple
coordinates, only one will be returned.
float[] | When the asking for the center (default). |
float | When asking for one coordinate only. |
gl, local, x, y, z
Long name (short name) |
Argument types |
Properties |
|
gl(gl)
|
boolean
|
|
|
Return positional values in global coordinates (default).
|
|
local(l)
|
boolean
|
|
|
Return positional values in local coordinates.
|
|
x(x)
|
boolean
|
|
|
y(y)
|
boolean
|
|
|
z(z)
|
boolean
|
|
|
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.
|
import maya.cmds as cmds
# create a simple hierarchy
cmds.polyCube( name='a' )
cmds.polyCube( name='b' )
cmds.parent( 'b', 'a' )
cmds.move( 3, 0, 0, 'a', localSpace=True )
cmds.move( 2, 2, 2, 'b', localSpace=True )
X_COORD = cmds.objectCenter('b',x=True)
# Result: 5 #
# Get the center of the bounding box of b in local space
XYZ = cmds.objectCenter('b', l=True)
# Result: 2 2 2 #
# Get the center of the bounding box of b in world space
XYZ = cmds.objectCenter('b', gl=True)
# Result: 5 2 2 #
# Get the center of the bounding box of a in world space
XYZ = cmds.objectCenter('a', gl=True)