pymel.core.general.objectCenter

objectCenter(*args, **kwargs)

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.

Flags:
Long name (short name) Argument Types Properties
gl (gl) bool ../../../_images/create.gif
 

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 ../../../_images/create.gif
 
Return positional values in local coordinates.
x (x) bool ../../../_images/create.gif
 
Return X value only
y (y) bool ../../../_images/create.gif
 
Return Y value only
z (z) bool ../../../_images/create.gif
 
Return Z value only

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)

Previous topic

pymel.core.general.objExists

Next topic

pymel.core.general.objectType

Core

Core Modules

Other Modules

This Page