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

- Class List
- Class Hierarchy
- Class Members

Public Types | Public Member Functions | Protected Member Functions

# MFnMotionPath Class Reference
OpenMayaAnim - API module for animation | FunctionSet classes

This reference page is linked to from the following overview topics: Appendix C: Frequently asked questions.

Search for all occurrences

## Detailed Description

Motion path animation function set.

This class is used for constructing and manipulating motion path animation.

Motion path animation requires a curve (or surface) and one or more other objects. During the animation, the objects will be moved along the curve.

Setting "follow" for the motion path aligns the object(s) local axis to the tangent of the motion path. Banking can also be applied to objects.

Motion path markers are points along the path where the orientation and position for the object(s) travelling along the path can be specified.

Examples:

  motionPathCmd.cpp.

`#include <MFnMotionPath.h>`

Inheritance diagram for MFnMotionPath:
[legend]

List of all members.

## Public Types
enum | Axis { kXaxis, kYaxis, kZaxis }
| Available axes. More...
## Public Member Functions
virtual MFn::Type | type () const
| Function set type.
virtual | ~MFnMotionPath ()
| Destructor.
| MFnMotionPath ()
| Default constructor.
| MFnMotionPath (MObject &object, MStatus *ReturnStatus=NULL)
| Constructor.
MObject | create (const MDagPath &pathObject, const MDagPath &objectToAnimate, MTime &timeStart, MTime &timeEnd, MDGModifier *modifier=NULL, MStatus *ReturnStatus=NULL)
| Create a new motion path dependency node.
MStatus | setPathObject (const MDagPath &pathObject, MDGModifier *modifier=NULL)
| Set the curve or surface for this motion path.
MDagPath | pathObject (MStatus *ReturnStatus=NULL)
| Return a dag path to the motion path object.
MStatus | addAnimatedObject (const MDagPath &objectToAnimate, MDGModifier *modifier=NULL)
| Add an object to be animated along this motion path.
MStatus | getAnimatedObjects (MDagPathArray &array)
| Returns an array of dag paths to the animated objects for this motion path.
MStatus | setFollow (bool on, MDGModifier *modifier=NULL)
| Setting follow on will cause the animated object(s) local axis to be aligned with the tangent of the motion path.
bool | follow (MStatus *ReturnStatus=NULL) const
| Determines whether follow is set for this motion path node.
MStatus | setFollowAxis (Axis axis)
| Sets the axis of the animated object that will follow the motion path.
Axis | followAxis (MStatus *ReturnStatus=NULL)
| Return the follow axis for this motion path.
MStatus | setUpAxis (Axis axis)
| Set the up-axis for this motion path.
Axis | upAxis (MStatus *ReturnStatus=NULL)
| Return the up-axis for this motion path.
MStatus | setBank (bool bank)
bool | bank (MStatus *ReturnStatus=NULL) const
| Determines whether bank has been enabled for this motion path.
MStatus | setBankScale (double bankScale)
| Set the bank scale for this motion path.
double | bankScale (MStatus *ReturnStatus=NULL)
| Return the bank scale for this motion path.
MStatus | setBankThreshold (double bankThreshold)
| Set the bank threshold for this motion path.
double | bankThreshold (MStatus *ReturnStatus=NULL)
| Return the bank threshold for this motion path.
MStatus | setUseNormal (bool use)
| If true, enables alignment of the up axis of the animated object to the normal vector of the path geometry.
bool | useNormal (MStatus *ReturnStatus=NULL)
| Determines whether the up-axis of the animated object for this motion path is aligned with the normal vector of the path geometry.
MStatus | setInverseNormal (bool invert)
| If true, enable alignment of the up axis of the moving object(s) to the opposite direction of the normal vector of the path geometry.
bool | inverseNormal (MStatus *ReturnStatus=NULL)
| Determines whether the up-axis of the animated object for this motion path is aligned to the opposite direction of the normal vector of the path geometry.
MStatus | setUStart (double start)
| Sets the starting value of the u parameterization for the animation.
MStatus | setUEnd (double end)
| Sets the end value of the u parameterization for the animation.
double | uStart (MStatus *ReturnStatus=NULL)
| Returns the starting value of the u parameterization for the animation.
double | uEnd (MStatus *ReturnStatus=NULL)
| Returns the end value of the u parameterization for the animation.
MStatus | setUTimeStart (MTime &start)
| Sets the starting time of the animation for the u parameter.
MStatus | setUTimeEnd (MTime &end)
| Sets the end time of the animation for the u parameter.
MTime | uTimeStart (MStatus *ReturnStatus=NULL)
| Returns the start time of the animation for the u parameter.
MTime | uTimeEnd (MStatus *ReturnStatus=NULL)
| Returns the end time of the animation for the u parameter.
unsigned int | numPositionMarkers (MStatus *ReturnStatus=NULL)
| Returns the number of position markers on this motion path.
MObject | getPositionMarker (unsigned int, MStatus *ReturnStatus=NULL)
| Gets the position marker where markerNum is the order in which the marker was created.
unsigned int | numOrientationMarkers (MStatus *ReturnStatus=NULL)
| Returns the number of orientation markers on this motion path.
MObject | getOrientationMarker (unsigned int, MStatus *ReturnStatus=NULL)
| Gets the orientation marker where markerNum is the order in which the marker was created.
| MFnMotionPath (const MObject &object, MStatus *ReturnStatus=NULL)
| Constructor.
## Protected Member Functions
virtual const char * | className () const
| Class name.

## Member Enumeration Documentation

enum Axis

Search for all occurrences

Available axes.

Enumerator:

  kXaxis | Search for all occurrences
  kYaxis | Search for all occurrences
  kZaxis | Search for all occurrences

## Constructor & Destructor Documentation

MFnMotionPath | ( | MObject & | object,
|  | MStatus * | ReturnStatus = `NULL`
| ) |  |

Constructor.

Class constructor that initializes the function set to the given MObject.

Parameters:

  [in] | object | The MObject to attach the function set to
  [out] | ReturnStatus | the return status

Status Codes:
  - MS::kSuccess if the function set is successfully attached
  - MS::kInvalidParameter if the MObject does not represent a valid Maya object or if the function set is not allowed to attach to this MObject

MFnMotionPath | ( | const MObject & | object,
|  | MStatus * | ReturnStatus = `NULL`
| ) |  |

Constructor.

Class constructor that initializes the function set to the given MObject.

Parameters:

  [in] | object | The MObject to attach the function set to
  [out] | ReturnStatus | the return status

Status Codes:
  - MS::kSuccess if the function set is successfully attached
  - MS::kInvalidParameter if the MObject does not represent a valid Maya object or if the function set is not allowed to attach to this MObject

## Member Function Documentation

MFn::Type type | ( |  | ) | const`[virtual]`

Search for all occurrences

Function set type.

Return the class type : MFn::kMotionPath.

Reimplemented from MFnDependencyNode.

const char * className | ( |  | ) | const`[protected, virtual]`

Search for all occurrences

Class name.

Return the class name : "MFnMotionPath".

Reimplemented from MFnDependencyNode.

MObject create | ( | const MDagPath & | pathObject,
|  | const MDagPath & | objectToAnimate,
|  | MTime & | timeStart,
|  | MTime & | timeEnd,
|  | MDGModifier * | modifier = `NULL`,
|  | MStatus * | ReturnStatus = `NULL`
| ) |  |

Search for all occurrences

Create a new motion path dependency node.

When a motion path node is created, the following defaults are set:

- Follow OFF
- Bank OFF
- BankScale 1.0
- BankThreshold 0.5 * PI

Parameters:

  [in] | pathObject | the curve, surface, or curve-on-surface to use as the object path
  [in] | objectToAnimate | the object that will follow the motion path
  [in] | timeStart | the time at which to start the animation
  [in] | timeEnd | the time at which to end the animation
  [in] | modifier | this object will hold the undo information
  [out] | ReturnStatus | Status Code

Returns:
  The new motion path node

Status Codes:
  - MS::kSuccess Member was successful
  - MS::kLicenseFailure application not licensed for attempted operation
  - MS::kFailure An object error has occurred

Examples:
  motionPathCmd.cpp.

MStatus setPathObject | ( | const MDagPath & | pathObject,
|  | MDGModifier * | modifier = `NULL`
| ) |  |

Search for all occurrences

Set the curve or surface for this motion path.

All animated objects for this motion path will follow the new path that is specified.

Parameters:

  [in] | pathObject | The curve (or surface) that will be the motion path
  [in] | modifier | The object that will hold the undo information

Returns:
  Status Code

Status Codes:
  - MS::kSuccess Member was successful
  - MS::kFailure An object error has occurred

MDagPath pathObject | ( | MStatus * | ReturnStatus = `NULL` | ) |

Search for all occurrences

Return a dag path to the motion path object.

The motion path object is the curve/surface that animated objects of this node will move along.

Parameters:

  [out] | ReturnStatus | Status Code

Returns:
  The dag path of the motion path object

Status Codes:
  - MS::kSuccess Member was successful
  - MS::kFailure An object error has occurred

MStatus addAnimatedObject | ( | const MDagPath & | objectToAnimate,
|  | MDGModifier * | modifier = `NULL`
| ) |  |

Search for all occurrences

Add an object to be animated along this motion path.

Parameters:

  [in] | objectToAnimate | A DAG path to the animated object
  [in] | modifier | The object that will hold the undo information

Returns:
  Status Code

Status Codes:
  - MS::kSuccess Member was successful
  - MS::kFailure An object error has occurred

MStatus getAnimatedObjects | ( | MDagPathArray & | array | ) |

Search for all occurrences

Returns an array of dag paths to the animated objects for this motion path.

Parameters:

  [out] | array | Storage for the dag paths.

Returns:
  Status Code

Status Codes:
  - MS::kSuccess Member was successful
  - MS::kFailure An object error has occurred

MStatus setFollow | ( | bool | on,
|  | MDGModifier * | modifier = `NULL`
| ) |  |

Search for all occurrences

Setting follow on will cause the animated object(s) local axis to be aligned with the tangent of the motion path.

The default alignment axis is Y.

Parameters:

  [in] | on | Specifies whether follow is activated for this motion path
  [in] | modifier | The object that will hold the undo information

Returns:
  Status Code

Status Codes:
  - MS::kSuccess Member was successful
  - MS::kFailure An object error has occurred

bool follow | ( | MStatus * | ReturnStatus = `NULL` | ) | const

Search for all occurrences

Determines whether follow is set for this motion path node.

Parameters:

  [out] | ReturnStatus | Status Code

Returns:
  - true Follow is turned on
  - false Follow is turned off

Status Codes:
  - MS::kSuccess Member was successful
  - MS::kFailure An object error has occurred

MStatus setFollowAxis | ( | MFnMotionPath::Axis | axis | ) |

Search for all occurrences

Sets the axis of the animated object that will follow the motion path.

Possible alignment parameters are kXaxis, kYaxiz, or kZaxis.

Parameters:

  [in] | axis | Object axis to align with motion path tangent

Returns:
  Status Code

Status Codes:
  - MS::kSuccess Member was successful
  - MS::kFailure An object error has occurred

MFnMotionPath::Axis followAxis | ( | MStatus * | ReturnStatus = `NULL` | ) |

Search for all occurrences

Return the follow axis for this motion path.

Parameters:

  [out] | ReturnStatus | Status Code

Returns:
  The follow axis.

Status Codes:
  - MS::kSuccess Member was successful
  - MS::kFailure An object error has occurred

MStatus setUpAxis | ( | MFnMotionPath::Axis | axis | ) |

Search for all occurrences

Set the up-axis for this motion path.

Parameters:

  [in] | axis | Axis to be set

Returns:
  Status Code

Status Codes:
  - MS::kSuccess Member was successful
  - MS::kFailure An object error has occurred

MFnMotionPath::Axis upAxis | ( | MStatus * | ReturnStatus = `NULL` | ) |

Search for all occurrences

Return the up-axis for this motion path.

Parameters:

  [out] | ReturnStatus | Status Code

Returns:
  The up-axis for this motion path

Status Codes:
  - MS::kSuccess Member was successful
  - MS::kFailure An object error has occurred

MStatus setBank | ( | bool | bank | ) |

Search for all occurrences

Parameters:

  [in] | bank | Specifies whether bank is turned on

Returns:
  Status Code

Status Codes:
  - MS::kSuccess Member was successful
  - MS::kFailure An object error has occurred

bool bank | ( | MStatus * | ReturnStatus = `NULL` | ) | const

Search for all occurrences

Determines whether bank has been enabled for this motion path.

Parameters:

  [out] | ReturnStatus | Status Code

Returns:
  - true Bank is enabled
  - false Bank is disabled

Status Codes:
  - MS::kSuccess Member was successful
  - MS::kFailure An object error has occurred

MStatus setBankScale | ( | double | bankScale | ) |

Search for all occurrences

Set the bank scale for this motion path.

If the computed bank angles are not large enough, the user can specify the bankScale to amplify them. The default value is 1.

Positive bankScale produces inward bank angle, negative bankScale produces outward bank angle.

Parameters:

  [in] | bankScale | The new bank scale value

Returns:
  Status Code

Status Codes:
  - MS::kSuccess Member was successful
  - MS::kFailure An object error has occurred

double bankScale | ( | MStatus * | ReturnStatus = `NULL` | ) |

Search for all occurrences

Return the bank scale for this motion path.

Parameters:

  [out] | ReturnStatus | Status Code

Returns:
  The bank scale.

Status Codes:
  - MS::kSuccess Member was successful
  - MS::kFailure An object error has occurred

MStatus setBankThreshold | ( | double | bankThreshold | ) |

Search for all occurrences

Set the bank threshold for this motion path.

The bank threshold is used to specify the maximum bank angle. The default value is 90 degrees.

Parameters:

  [in] | bankThreshold | The new bank threshold value

Returns:
  Status Code

Status Codes:
  - MS::kSuccess Member was successful
  - MS::kFailure An object error has occurred

double bankThreshold | ( | MStatus * | ReturnStatus = `NULL` | ) |

Search for all occurrences

Return the bank threshold for this motion path.

The bank threshold is used to specify the maximum bank angle. The default value is 90 degrees.

Parameters:

  [out] | ReturnStatus | Status Code

Returns:
  The bank threshold.

Status Codes:
  - MS::kSuccess Member was successful
  - MS::kFailure An object error has occurred

MStatus setUseNormal | ( | bool | use | ) |

Search for all occurrences

If true, enables alignment of the up axis of the animated object to the normal vector of the path geometry.

Parameters:

  [in] | use | Specifies if normal is used

Returns:
  Status Code

Status Codes:
  - MS::kSuccess Member was successful
  - MS::kFailure An object error has occurred

bool useNormal | ( | MStatus * | ReturnStatus = `NULL` | ) |

Search for all occurrences

Determines whether the up-axis of the animated object for this motion path is aligned with the normal vector of the path geometry.

Parameters:

  [out] | ReturnStatus | Status Code

Returns:
  - true Normal vector is used for object alignment.
  - false Normal vector is not used for object alignment.

Status Codes:
  - MS::kSuccess Member was successful
  - MS::kFailure An object error has occurred

MStatus setInverseNormal | ( | bool | invert | ) |

Search for all occurrences

If true, enable alignment of the up axis of the moving object(s) to the opposite direction of the normal vector of the path geometry.

Parameters:

  [in] | invert | Specifies if inverse normal is used

Returns:
  Status Code

Status Codes:
  - MS::kSuccess Member was successful
  - MS::kFailure An object error has occurred

bool inverseNormal | ( | MStatus * | ReturnStatus = `NULL` | ) |

Search for all occurrences

Determines whether the up-axis of the animated object for this motion path is aligned to the opposite direction of the normal vector of the path geometry.

Parameters:

  [out] | ReturnStatus | Status Code

Returns:
  - true Inverse normal vector is used for object alignment.
  - false Inverse normal vector is not used for object alignment.

Status Codes:
  - MS::kSuccess Member was successful
  - MS::kFailure An object error has occurred

MStatus setUStart | ( | double | start | ) |

Search for all occurrences

Sets the starting value of the u parameterization for the animation.

Parameters:

  [in] | start | the new start value

Returns:
  Status Code

Status Codes:
  - MS::kSuccess Member was successful
  - MS::kFailure An object error has occurred

MStatus setUEnd | ( | double | end | ) |

Search for all occurrences

Sets the end value of the u parameterization for the animation.

Parameters:

  [in] | end | the new end value

Returns:
  Status Code

Status Codes:
  - MS::kSuccess Member was successful
  - MS::kFailure An object error has occurred

double uStart | ( | MStatus * | ReturnStatus = `NULL` | ) |

Search for all occurrences

Returns the starting value of the u parameterization for the animation.

Parameters:

  [out] | ReturnStatus | Status Code

Returns:
  The starting value

Status Codes:
  - MS::kSuccess Member was successful
  - MS::kFailure An object error has occurred

double uEnd | ( | MStatus * | ReturnStatus = `NULL` | ) |

Search for all occurrences

Returns the end value of the u parameterization for the animation.

Parameters:

  [out] | ReturnStatus | Status Code

Returns:
  The end value

Status Codes:
  - MS::kSuccess Member was successful
  - MS::kFailure An object error has occurred

MStatus setUTimeStart | ( | MTime & | start | ) |

Search for all occurrences

Sets the starting time of the animation for the u parameter.

Parameters:

  [in] | start | the new start time

Returns:
  Status code

Status Codes:
  - MS::kSuccess Member was successful
  - MS::kFailure An object error has occurred

MStatus setUTimeEnd | ( | MTime & | end | ) |

Search for all occurrences

Sets the end time of the animation for the u parameter.

Parameters:

  [in] | end | the new end time

Returns:
  Status code

Status Codes:
  - MS::kSuccess Member was successful
  - MS::kFailure An object error has occurred

MTime uTimeStart | ( | MStatus * | ReturnStatus = `NULL` | ) |

Search for all occurrences

Returns the start time of the animation for the u parameter.

Parameters:

  [out] | ReturnStatus | Status Code

Returns:
  The starting time

Status Codes:
  - MS::kSuccess Member was successful
  - MS::kFailure An object error has occurred

MTime uTimeEnd | ( | MStatus * | ReturnStatus = `NULL` | ) |

Search for all occurrences

Returns the end time of the animation for the u parameter.

Parameters:

  [out] | ReturnStatus | Status Code

Returns:
  The end time

Status Codes:
  - MS::kSuccess Member was successful
  - MS::kFailure An object error has occurred

unsigned int numPositionMarkers | ( | MStatus * | ReturnStatus = `NULL` | ) |

Search for all occurrences

Returns the number of position markers on this motion path.

Parameters:

  [out] | ReturnStatus | Status Code

Returns:
  The number of markers

Status Codes:
  - MS::kSuccess Member was successful
  - MS::kFailure An object error has occurred

MObject getPositionMarker | ( | unsigned int | markerNum,
|  | MStatus * | ReturnStatus = `NULL`
| ) |  |

Search for all occurrences

Gets the position marker where markerNum is the order in which the marker was created.

Parameters:

  [in] | markerNum | The number of the marker
  [out] | ReturnStatus | Status Code

Returns:
  The position marker

Status Codes:
  - MS::kSuccess Member was successful
  - MS::kFailure An object error has occurred

unsigned int numOrientationMarkers | ( | MStatus * | ReturnStatus = `NULL` | ) |

Search for all occurrences

Returns the number of orientation markers on this motion path.

Parameters:

  [out] | ReturnStatus | Status Code

Returns:
  The number of markers

Status Codes:
  - MS::kSuccess Member was successful
  - MS::kFailure An object error has occurred

MObject getOrientationMarker | ( | unsigned int | markerNum,
|  | MStatus * | ReturnStatus = `NULL`
| ) |  |

Search for all occurrences

Gets the orientation marker where markerNum is the order in which the marker was created.

Parameters:

  [in] | markerNum | The number of the marker
  [out] | ReturnStatus | Status Code

Returns:
  The orientation marker

Status Codes:
  - MS::kSuccess Member was successful
  - MS::kFailure An object error has occurred

MFnMotionPath MFnMotionPath MFnMotionPath MFnMotionPath MFnMotionPath MFnMotionPath MFnMotionPath MFnMotionPath MFnMotionPath MFnMotionPath
MFnMotionPath MFnMotionPath MFnMotionPath MFnMotionPath MFnMotionPath MFnMotionPath MFnMotionPath MFnMotionPath MFnMotionPath MFnMotionPath