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 | ||
|
|||
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
# 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)
5
# Get the center of the bounding box of b in local space
XYZ = pm.objectCenter('b', l=True)
2 2 2
# Get the center of the bounding box of b in world space
XYZ = pm.objectCenter('b', gl=True)
5 2 2
# Get the center of the bounding box of a in world space
XYZ = pm.objectCenter('a', gl=True)