Go to: Synopsis. Return value. Flags. MEL examples.

Synopsis

objectCenter [-global] [-local] [-x] [-y] [-z] object

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.

Return value

float[]When the asking for the center (default).
floatWhen asking for one coordinate only.

Flags

global, local, x, y, z
Long name (short name) Argument types Properties
-x(-x) create
Return X value only
-y(-y) create
Return Y value only
-z(-z) create
Return Z value only
-local(-l) create
Return positional values in local coordinates.
-global(-gl) create
Return positional values in global coordinates (default).

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 be used more than once in a command.

MEL examples

// create a simple hierarchy
polyCube -name "a";
polyCube -name "b";
parent b a;
move -localSpace 3 0 0 a;
move -localSpace 2 2 2 b;

// Get the world space x coordinate value of object b's center
float $X_COORD = `objectCenter -x b`;
// Result: 5 //

// Get the center of the bounding box of b in local space
float $XYZ[] = `objectCenter -l b`;
// Result: 2 2 2 //

// Get the center of the bounding box of b in world space
float $XYZ[] = `objectCenter -gl b`;
// Result: 5 2 2 //

// Get the center of the bounding box of a in world space
float $XYZ[] = `objectCenter -gl a`;
// Result: 4 1 1 //