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

- Class List
- Class Hierarchy
- Class Members

Public Types | Public Member Functions | Protected Member Functions

# MFnExpression Class Reference
OpenMaya - API module for common classes | FunctionSet classes

Search for all occurrences

## Detailed Description

Expression function set.

This class is used to create, edit, and query expression nodes.

`#include <MFnExpression.h>`

Inheritance diagram for MFnExpression:
[legend]

List of all members.

## Public Types
enum | UnitConversion { kAll, kNone, kAngularOnly }
| Unit conversion modes. More...
## Public Member Functions
virtual MFn::Type | type () const
| Function set type.
virtual | ~MFnExpression ()
| Destructor.
| MFnExpression ()
| Default constructor.
| MFnExpression (MObject &object, MStatus *ReturnStatus=NULL)
| Constructor.
MObject | create (const MString &expression, MObject &object=MObject::kNullObj, MStatus *ReturnStatus=NULL)
| This method creates and returns a dependency node for a given expression.
MString | expression (MStatus *ReturnStatus=NULL)
| Gets the expression string for this expression node.
MStatus | setExpression (const MString &expression)
| Sets the expression string for this expression node.
MStatus | getDefaultObject (MObject &object)
| Gets the "default" object for the expression.
MStatus | setDefaultObject (MObject &object)
| Sets the "default" object for the expression.
bool | isAnimated (MStatus *ReturnStatus=NULL)
| If this is true, then the expression will be evaluated whenever time changes, regardless of whether the other inputs have changed.
MStatus | setAnimated (bool value=false)
| Sets the way in which the expression is evaluated.
MStatus | evaluate (MDoubleArray &result)
| Evaluate this expression and return the result.
UnitConversion | unitConversion (MStatus *ReturnStatus=NULL) const
| Get the unit conversion status for the expression node.
MStatus | setUnitConversion (UnitConversion conversion)
| Set the unit conversion options for the expression node.
| MFnExpression (const MObject &object, MStatus *ReturnStatus=NULL)
| Constructor.
MStatus | getExpression (MString &expression)
| NO SCRIPT SUPPORT.
## Protected Member Functions
virtual const char * | className () const
| Class name.

## Member Enumeration Documentation

enum UnitConversion

Search for all occurrences

Unit conversion modes.

Enumerator:

  kAll | Convert all units. Search for all occurrences
  kNone | Do not do any unit conversion. Search for all occurrences
  kAngularOnly | Only convert angular units. Search for all occurrences

## Constructor & Destructor Documentation

MFnExpression | ( | 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

MFnExpression | ( | 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::kExpression.

Reimplemented from MFnDependencyNode.

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

Search for all occurrences

Class name.

Return the class name : "MFnExpression".

Reimplemented from MFnDependencyNode.

MObject create | ( | const MString & | expression,
|  | MObject & | object = `MObject::kNullObj`,
|  | MStatus * | ReturnStatus = `NULL`
| ) |  |

Search for all occurrences

This method creates and returns a dependency node for a given expression.

A default object can be specified, but if it is not specified in the expression string then the expression string values will be used.

If the expression string is of the form "objectName.attribute = ... " then the default object parameter is not needed. If you supply a default object in this case, then it will be ignored.

If the expression has no default object then you must supply one. For example, if the expression is of the form "attribute = ...", then you must supply a default object.

Parameters:

  [in] | expression | The expression string
  [in] | object | The default object (optional - see above)
  [out] | ReturnStatus | Status code

Returns:
  The expression node

Status Codes:
  - MS::kSuccess
  - MS::kLicenseFailure application not licensed for attempted operation
  - MS::kFailure

MString expression | ( | MStatus * | ReturnStatus = `NULL` | ) |

Search for all occurrences

Gets the expression string for this expression node.

Parameters:

  [out] | ReturnStatus | Status code. See below.

Returns:
  The expression string

Status Codes:
  - MS::kSuccess
  - MS::kFailure

MStatus setExpression | ( | const MString & | expression | ) |

Search for all occurrences

Sets the expression string for this expression node.

Parameters:

  [in] | expression | The expression string

Returns:
  Status Code

Status Codes:
  - MS::kSuccess
  - MS::kFailure

MStatus getDefaultObject | ( | MObject & | object | ) |

Search for all occurrences

Gets the "default" object for the expression.

Not all expressions have a default object. If there is no default object for the expression, the object will be set to MObject::kNullObject and the return status will indicate success. This is a completely legal case that the calling code should check for before blindly using the returned object.

Parameters:

  [out] | object | storage for the default object

Returns:
  Status Code

Status Codes:
  - MS::kSuccess
  - MS::kFailure

MStatus setDefaultObject | ( | MObject & | object | ) |

Search for all occurrences

Sets the "default" object for the expression.

This allows the expression writer to not type the object name for frequently-used objects.

This method will only work for expression strings in which the object name is not specified.

Parameters:

  [in] | object | the object to be set

Returns:
  Status Code

Status Codes:
  - MS::kSuccess
  - MS::kFailure

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

Search for all occurrences

If this is true, then the expression will be evaluated whenever time changes, regardless of whether the other inputs have changed.

If it is false (the default) , then the expression will only be evaluated if one or more of the inputs change.

Note, if 'time' or 'frame' are inputs, then the expression will act as if this was set to true.

Parameters:

  [out] | ReturnStatus | Status code

Returns:
  - true expression will be evaluated whenever time changes
  - false

Status Codes:
  - MS::kSuccess
  - MS::kFailure

MStatus setAnimated | ( | bool | value = `false` | ) |

Search for all occurrences

Sets the way in which the expression is evaluated.

If this is true, then the expression will be evaluated whenever time changes, regardless of whether the other inputs have changed.

If it is false (the default) , then the expression will only be evaluated if one or more of the inputs change.

Note, if 'time' or 'frame' are inputs, then the expression will act as if this was set to true.

Parameters:

  [in] | value | sets the objects evaluation type

Returns:
  Status Code

Status Codes:
  - MS::kSuccess
  - MS::kFailure

MStatus evaluate | ( | MDoubleArray & | result | ) |

Search for all occurrences

Evaluate this expression and return the result.

Parameters:

  [out] | result | the value of the expression

Returns:
  Status code

Status Codes:
  - MS::kSuccess
  - MS::kFailure

MFnExpression::UnitConversion unitConversion | ( | MStatus * | ReturnStatus = `NULL` | ) | const

Search for all occurrences

Get the unit conversion status for the expression node.

Parameters:

  [out] | ReturnStatus | Status code

Returns:
  The unit conversion state for this node

Status Codes:
  - MS::kSuccess operation successful
  - MS::kFailure function set does not have a valid object

MStatus setUnitConversion | ( | UnitConversion | conversion | ) |

Search for all occurrences

Set the unit conversion options for the expression node.

Parameters:

  [in] | conversion | unit conversion state for this node

Returns:
  Status code

Status Codes:
  - MS::kSuccess operation successful
  - MS::kFailure function set does not have a valid object

MStatus getExpression | ( | MString & | expression | ) |

Search for all occurrences

NO SCRIPT SUPPORT.

Gets the expression string for this expression node.

Python Notes

This method is not supported in Python. Please see the one which returns a string

Parameters:

  [in] | expression | The expression string

Returns:
  Status code

Status Codes:
  - MS::kSuccess
  - MS::kFailure

MFnExpression MFnExpression MFnExpression MFnExpression MFnExpression MFnExpression MFnExpression MFnExpression MFnExpression MFnExpression
MFnExpression MFnExpression MFnExpression MFnExpression MFnExpression MFnExpression MFnExpression MFnExpression MFnExpression MFnExpression