MObject Class Reference

+ Related help topics:

#include <MObject.h>

Class Description

Generic Class for Accessing Internal Maya Objects.

Determine the exact type (MFn::Type) of an MObject within Maya.

Determine if an Object exists.

Determine if an Object is compatible with a specific Function Set.

MObject is the generic class for accessing all Maya internal modelling, animation and rendering Objects, collectively referred to as Model Objects, through the API. This includes all Dependency Graph (DG) Nodes, of which Directed Acyclic Graph (DAG) Nodes are a subset.

Each instance of an MObject represents a specific Node or Attribute on a Node in the DG. Under the C++ class scheme MObjects simply have type MObject with no base or derived hierarchy. However, MObjects may be many different types of Model objects, from Attributes to transforms, including components of geometry such as Control Vertices (CV), faces, edges and vertices. This allows many different types of objects to be moved accessed through the API without undue concern on the part of plug-in developers for the type of object being manipulated.

Since it is impractical to provide every applicable method in MObjects, the methods applicable to Maya Objects are encapsulated in Function Sets. Function Sets can be attached to compatible MObjects to provide an external interface to methods appropriate to that MObject.

The link between an MObject and the role it performs as a Maya Model object, as well as the compatibility between MObjects and Function Sets is managed by the API Run-Time Type Identification (RTTI) system. The two key concepts of this system are the Maya Object type and the Function Set type (both in MFn::Type). All MObjects have one and only one Maya Object type. All Function Sets have one and only one Function Set type. MObjects may, however, be compatible with many types of Function Sets. This compatibility follows the class hierarchy of the Function Sets. Thus an MObject with Maya Object type MFn::kNurbsSurface would be compatible with MFnNurbsSurface, MFnDagNode, MFnDependencyNode, MFnNamedObject and MFnBase.

Use the apiType() method to determine the type (MFn::Type) of the Maya Model Object.

Use hasFn() to determine if the Object is comaptible with a given Function Set.

Use isNull() to determine if the internal Maya Object exists.

+ Examples:

Public Member Functions

 MObject ()
 Class Constructor. More...
 
 MObject (const MObject &other)
 Class Copy Constructor. More...
 
 ~MObject ()
 The class destructor. More...
 
bool hasFn (MFn::Type fs) const
 Determines the whether or not the internal Object is compatible with the given Function Type. More...
 
bool isNull () const
 Determines the whether or not an internal Object exists. More...
 
MFn::Type apiType () const
 Determines the exact type of the Maya internal Object. More...
 
const char * apiTypeStr () const
 Returns a string that gives the object's type is a readable form. More...
 
bool operator== (const MObject &) const
 The comparison operator. More...
 
bool operator!= (const MObject &) const
 The inequality operator. More...
 
MObjectoperator= (const MObject &)
 The assignment operator. More...
 

Static Public Attributes

static MObject kNullObj
 Null Object for use as default argument.
 

Friends

class MObjectHandle
 

Constructor & Destructor Documentation

MObject ( )

Class Constructor.

Creates an MObject. Initializes it as a null Object.

MObject ( const MObject other)

Class Copy Constructor.

Creates an MObject. Copies the object passed in.

Parameters
[in]otherMObject to copy from
~MObject ( )

The class destructor.

Destroys the current object if nothing refers to it.

Member Function Documentation

bool hasFn ( MFn::Type  fs) const

Determines the whether or not the internal Object is compatible with the given Function Type.

Parameters
[in]fsFunction Set type
Returns
  • true Is compatible
  • false Is not compatible, or is null (object does not exist).
+ Examples:
bool isNull ( ) const

Determines the whether or not an internal Object exists.

Returns
  • true Object does not exist
  • false Object exists
+ Examples:
const char * apiTypeStr ( ) const

Returns a string that gives the object's type is a readable form.

This is useful for debugging when type of an object needs to be printed.

If the object does not exist (is null), returns "kInvalid".

Returns
  • a string containing the type name of the object
+ Examples:
bool operator== ( const MObject other) const

The comparison operator.

Returns true if both MObjects refer to the same Maya object.

bool operator!= ( const MObject other) const

The inequality operator.

Returns true if the MObjects refer to different Maya objects.

MObject & operator= ( const MObject other)

The assignment operator.

Destroys the current object if no other MObjects refer to it. Points this object to the passed in object.


The documentation for this class was generated from the following files:
  • MObject.h
  • MObject.cpp