Share

MObject and function sets

Maya's internal modelling, animation and rendering objects, as well as all the directed graph nodes and their attributes, are referred to as model objects.

Function set classes, which have the MFn prefix, provide functions for manipulating specific model objects. For example, MFnNurbsSurface provides functions for manipulating NURBS surfaces.

The MObject class provides a generic interface to access model objects. Each MObject is a handle to the underlying model object that is being manipulated by the function set. As such, calling the destructor on the MObject will only destroy the MObject and not the underlying model object it represents.

An MObject is created with a function set's create() method. Each function set implements its own create() method and the MObject it creates acquires that function set's type. Because of inheritance, the MObject will be compatible with all the function sets from which its function set type was derived.

Note:

An MObject will not be compatible with function sets that are derived from its function set type.

Various methods are available to query an MObject's type. If you are unsure of the type of an MObject, use the apiType() method to get the MObject's type. The return value will be a type in MFn::Type. If you want to know if an MObject is compatible with a specific function set, pass the function set type to the hasFn() method.

Because MObject is a generic type, passing an MObject to an incompatible function set will not generate a compiler error. An error will only be generated at runtime.

Was this information helpful?