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.
Long name (short name) | Argument Types | Properties | |
---|---|---|---|
gl (gl) | bool | ||
Return positional values in global coordinates (default).Flag can appear in Create mode of commandFlag can have multiple arguments, passed either as a tuple or a list. |
|||
local (l) | bool | ||
|
|||
x (x) | bool | ||
|
|||
y (y) | bool | ||
|
|||
z (z) | bool | ||
|
Derived from mel command maya.cmds.objectCenter
Example:
import pymel.core as pm
import maya.cmds as cmds
# create a simple hierarchy
pm.polyCube( name='a' )
# Result: [nt.Transform(u'a'), nt.PolyCube(u'polyCube1')] #
pm.polyCube( name='b' )
# Result: [nt.Transform(u'b'), nt.PolyCube(u'polyCube2')] #
pm.parent( 'b', 'a' )
# Result: [u'b'] #
pm.move( 3, 0, 0, 'a', localSpace=True )
pm.move( 2, 2, 2, 'b', localSpace=True )
X_COORD = pm.objectCenter('b',x=True)
# Get the center of the bounding box of b in local space
XYZ = pm.objectCenter('b', l=True)
# Get the center of the bounding box of b in world space
XYZ = pm.objectCenter('b', gl=True)
# Get the center of the bounding box of a in world space
XYZ = pm.objectCenter('a', gl=True)