Go to: Synopsis. Return value. Flags. MEL examples.
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.
float[] | When the asking for the center (default). |
float | When asking for one coordinate only. |
global, local, x, y, z
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.
|
// 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 //