- Main Page
- Related Pages
- Modules
- Classes
- Examples

- Class List
- Class Hierarchy
- Class Members

Public Types | Public Member Functions | Static Public Member Functions

# MDistance Class Reference
OpenMaya - API module for common classes

Search for all occurrences

## Detailed Description

Manipulate Linear Data.

The MDistance class provides a fundamental type for the Maya API to hold and manipulate linear data. All API methods that require or return distance information do so through variables of this type.

Examples:

  animFileExport.cpp, animFileUtils.cpp, cgfxAttrDef.cpp, footPrintManip.cpp, footPrintNode.cpp, and swissArmyManip.cpp.

`#include <MDistance.h>`

List of all members.

## Public Types
enum | Unit { , kInches, kFeet, kYards, kMiles, kMillimeters, kCentimeters, kKilometers, kMeters }
| Available Unit Systems. More...
## Public Member Functions
| MDistance ()
| The default class constructor.
| MDistance (double value, Unit unitSystem=kCentimeters)
| Class constructor.
| MDistance (const MDistance &src)
| Copy constructor.
| ~MDistance ()
| The class destructor.
MDistance & | operator= (const MDistance &src)
| The assignment operator.
Unit | unit () const
| Return the units currently in effect for this instance.
double | value () const
| Return the value of the current instance in the currently set units.
MStatus | setUnit (Unit newUnit)
| Set the units used by this instance.
MStatus | setValue (double newValue)
| Set the value of this instance.
double | as (Unit newUnit, MStatus *ReturnStatus=NULL) const
| Return the current value of this instance in the provided units.
double | asUnits (Unit newUnit, MStatus *ReturnStatus=NULL) const
| Return the current value of this instance in the provided units.
double | asInches () const
| Return the current value of this instance in inches.
double | asFeet () const
| Return the current value of this instance in feet.
double | asYards () const
| Return the current value of this instance in yards.
double | asMiles () const
| Return the current value of this instance in miles.
double | asMillimeters () const
| Return the current value of this instance in millimeters.
double | asCentimeters () const
| Return the current value of this instance in centimeters.
double | asKilometers () const
| Return the current value of this instance in kilometers.
double | asMeters () const
| Return the current value of this instance in meters.
## Static Public Member Functions
static Unit | uiUnit ()
| Returns the Working Units (or UI units) chosen in the settings of the prefs window.
static MStatus | setUIUnit (Unit newUnit)
| Set the unit system to be used by the user in the UI.
static Unit | internalUnit ()
| Returns the internal unit system.
static double | internalToUI (double internalValue)
| Converts a value from internal units to UI units.
static double | uiToInternal (double uiValue)
| Converts a value from UI units to internal units.
static const char * | className ()
| Returns the name of this class.
static MStatus | setInternalUnit (Unit internalUnit)
| This method is obsolete.

## Member Enumeration Documentation

enum Unit

Search for all occurrences

Available Unit Systems.

Enumerator:

  kInches | Inches. Search for all occurrences
  kFeet | Feet. Search for all occurrences
  kYards | Yards. Search for all occurrences
  kMiles | Miles. Search for all occurrences
  kMillimeters | Millimeters. Search for all occurrences
  kCentimeters | Centimeters. Search for all occurrences
  kKilometers | Kilometers. Search for all occurrences
  kMeters | Meters. Search for all occurrences

## Constructor & Destructor Documentation

MDistance | ( |  | ) |

The default class constructor.

Initialize the MDistance instance to 0 in the current internal units. (See setInternalUnit and internalUnit below).

MDistance | ( | double | newValue,
|  | MDistance::Unit | newUnit = `kCentimeters`
| ) |  |

Class constructor.

Initialize the MDistance instance to the given value in the given unit system

Parameters:

  [in] | newValue | the initial value of the instance
  [in] | newUnit | the unit system for the initial value

MDistance | ( | const MDistance & | src | ) |

Copy constructor.

Parameters:

  [in] | src | Existing MDistance object from which to initialize the new one.

## Member Function Documentation

MDistance & operator= | ( | const MDistance & | src | ) |

The assignment operator.

Parameters:

  [in] | src | Existing MDistance object from which to set the value of this one.

Returns:
  Reference to this MDistance instance.

MDistance::Unit unit | ( |  | ) | const

Search for all occurrences

Return the units currently in effect for this instance.

Returns:
  An element of the MDistance::Unit enum

double value | ( |  | ) | const

Search for all occurrences

Return the value of the current instance in the currently set units.

Returns:
  The current value of the instance

MStatus setUnit | ( | MDistance::Unit | newUnit | ) |

Search for all occurrences

Set the units used by this instance.

Parameters:

  [in] | newUnit | an element of the MDistance::Unit enum

Returns:
  MS::kSuccess if a valid unit was provided, MS::kFailure otherwise

MStatus setValue | ( | double | newValue | ) |

Search for all occurrences

Set the value of this instance.

Parameters:

  [in] | newValue | the new value in the units currently in effect

Returns:
  Always returns MS::kSuccess

double as | ( | MDistance::Unit | otherUnit,
|  | MStatus * | ReturnStatus = `NULL`
| ) |  | const

Search for all occurrences

Return the current value of this instance in the provided units.

Parameters:

  [in] | otherUnit | an element of the MDistance::Unit enum specifying the desired units
  [out] | ReturnStatus | return status

Returns:
  The current value in the given units

Status Codes:
  - MS::kSuccess operation successful
  - MS::kFailure operation failed

Examples:
  cgfxAttrDef.cpp.

double asUnits | ( | MDistance::Unit | otherUnit,
|  | MStatus * | ReturnStatus = `NULL`
| ) |  | const

Search for all occurrences

Return the current value of this instance in the provided units.

Parameters:

  [in] | otherUnit | an element of the MDistance::Unit enum specifying the desired units
  [out] | ReturnStatus | return status

Returns:
  The current value in the given units

Status Codes:
  - MS::kSuccess operation successful
  - MS::kFailure operation failed

double asInches | ( |  | ) | const

Search for all occurrences

Return the current value of this instance in inches.

Returns:
  The current value in the inches

double asFeet | ( |  | ) | const

Search for all occurrences

Return the current value of this instance in feet.

Returns:
  The current value in the feet

double asYards | ( |  | ) | const

Search for all occurrences

Return the current value of this instance in yards.

Returns:
  The current value in the yards

double asMiles | ( |  | ) | const

Search for all occurrences

Return the current value of this instance in miles.

Returns:
  The current value in the miles

double asMillimeters | ( |  | ) | const

Search for all occurrences

Return the current value of this instance in millimeters.

Returns:
  The current value in the millimeters

double asCentimeters | ( |  | ) | const

Search for all occurrences

Return the current value of this instance in centimeters.

Returns:
  The current value in the centimeters

Examples:
  footPrintManip.cpp, footPrintNode.cpp, and swissArmyManip.cpp.

double asKilometers | ( |  | ) | const

Search for all occurrences

Return the current value of this instance in kilometers.

Returns:
  The current value in the kilometers

double asMeters | ( |  | ) | const

Search for all occurrences

Return the current value of this instance in meters.

Returns:
  The current value in the meters

MDistance::Unit uiUnit | ( |  | ) | `[static]`

Search for all occurrences

Returns the Working Units (or UI units) chosen in the settings of the prefs window.

Returns:
  An element of the MDistance::Unit enum

Examples:
  animFileExport.cpp, animFileUtils.cpp, and objExport.cpp.

MStatus setUIUnit | ( | MDistance::Unit | newUnit | ) | `[static]`

Search for all occurrences

Set the unit system to be used by the user in the UI.

Parameters:

  [in] | newUnit | and element of the MDistance::Unit enum.

Returns:
  MS::kSuccess if a valid unit was provided, MS::kFailure otherwise

Examples:
  animFileUtils.cpp.

MDistance::Unit internalUnit | ( |  | ) | `[static]`

Search for all occurrences

Returns the internal unit system.

Returns:
  The internal unit for distance

Examples:
  animFileUtils.cpp, and cgfxAttrDef.cpp.

double internalToUI | ( | double | internalValue | ) | `[static]`

Search for all occurrences

Converts a value from internal units to UI units.

Parameters:

  [in] | internalValue | a value in internal units

Returns:
  The value in UI units

Examples:
  objExport.cpp.

double uiToInternal | ( | double | uiValue | ) | `[static]`

Search for all occurrences

Converts a value from UI units to internal units.

Parameters:

  [in] | uiValue | a value in UI units

Returns:
  The value in internal units.

const char * className | ( |  | ) | `[static]`

Search for all occurrences

Returns the name of this class.

Returns:
  The name of this class.

MStatus setInternalUnit | ( | MDistance::Unit | internalUnit | ) | `[static]`

Search for all occurrences

This method is obsolete.

Deprecated:

Changing the internal units is generally not a good idea and using the method may often produce unexpected results. It is recommended to just read the values and convert them to the units desired.

Set the internal unit system.

Parameters:

  [in] | internalUnit | the internal unit to be used by distance

Returns:
  Status code

Status Codes:
  - MS::kSuccess a valid unit was provided
  - MS::kFailure a valid unit was not provided

MDistance MDistance MDistance MDistance MDistance MDistance MDistance MDistance MDistance MDistance
MDistance MDistance MDistance MDistance MDistance MDistance MDistance MDistance MDistance MDistance