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

- Class List
- Class Hierarchy
- Class Members

Public Member Functions | Static Public Attributes | Friends

# MObject Class Reference
OpenMaya - API module for common classes

This reference page is linked to from the following overview topics: MObject, Objects and Function Sets, Naming Conventions, Autodesk Maya 2014, Querying the Scene Graph, Creating and Manipulating Objects, The Dependency Graph, Dependency Graph Plug-ins, MSelectionList, setObject() method, MFn::Type enumeration, initializePlugin(), MPxCommand, DAG paths, Communication Between Manipulators and Nodes, Components, Anatomy of a shading node plug-in, The five basic polygonal API classes, polyModifierCmd example, splitUVCmd example, Using the Maya Python API, Differences between the Maya .NET API and the Maya C++ API, Writing your own .NET plug-in, Appendix C: Frequently asked questions, Appendix D: API and Devkit limitations.

Search for all occurrences

## Detailed 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:

  affectsNode.cpp, animCubeNode.cpp, animExportUtil.cpp, animExportUtil.h, animFileExport.cpp, animFileExport.h, animFileUtils.cpp, animFileUtils.h, animImportExport.cpp, animInfoCmd.cpp, anisotropicShader.cpp, apiMeshCreator.cpp, apiMeshCreator.h, apiMeshData.cpp, apiMeshData.h, apiMeshIterator.cpp, apiMeshIterator.h, apiMeshShape.cpp, apiMeshShape.h, apiMeshShapeUI.cpp, apiSimpleShape.cpp, apiSimpleShape.h, apiSimpleShapeIterator.cpp, apiSimpleShapeIterator.h, apiSimpleShapeUI.cpp, arcLenNode.cpp, backfillShader.cpp, blindComplexDataCmd.cpp, blindDataMesh.cpp, blindDataMesh.h, blindDataPluginMain.cpp, blindDataShader.cpp, blindDoubleDataCmd.cpp, blindShortDataCmd.cpp, brickShader.cpp, buildRotationNode.cpp, cellShader.cpp, cgfxAttrDef.cpp, cgfxAttrDef.h, cgfxShaderCmd.cpp, cgfxShaderCmd.h, cgfxShaderNode.cpp, cgfxShaderNode.h, cgfxVector.cpp, cgfxVector.h, checkerShader.cpp, circleNode.cpp, cleanPerFaceAssignmentPluginMain.cpp, clearcoat.cpp, closestPointCmd.cpp, closestPointOnCurveNode.cpp, closestPointOnCurveNode.h, closestPointOnCurvePlugin.cpp, closestPointOnNurbsSurfaceCmd.cpp, closestTangentUAndDistance.cpp, closestTangentUAndDistance.h, clothPaintAttrCmd.cpp, clusterWeightFunction.cpp, componentScaleManip.cpp, compositingShader.cpp, conditionTest.cpp, contrastShader.cpp, convertBumpCmd.cpp, convertEdgesToFacesCmd.cpp, convertVerticesToEdgesCmd.cpp, convertVerticesToFacesCmd.cpp, createClipCmd.cpp, curvedArrowsNode.cpp, customAttrManip.cpp, customImagePlane.cpp, cvColorNode.cpp, cvColorShader.cpp, cvExpandCmd.cpp, cvPosCmd.cpp, D3DResourceManager.cpp, D3DResourceManager.h, D3DTextureItem.h, D3DViewportRenderer.cpp, D3DViewportRenderer.h, D3DViewportRendererPlugin.cpp, dagMessageCmd.cpp, dagPoseInfoCmd.cpp, ddsFloatReader.cpp, deletedMsgCmd.cpp, depthShader.cpp, displacementShader.cpp, dynExprField.cpp, dynExprField.h, eventTest.cpp, exampleMRampAttribute.cpp, exportJointClusterDataCmd.cpp, exportSkinClusterDataCmd.cpp, fileIOMsgCmd.cpp, filteredAsciiFile.cpp, findFileTexturesCmd.cpp, findTexturesPerPolygonCmd.cpp, flameShader.cpp, flipUVCmd.cpp, flipUVCmd.h, flipUVMain.cpp, fluidInfoCmd.cpp, footPrintManip.cpp, footPrintNode.cpp, fullLoftNode.cpp, gammaShader.cpp, genericAttributeNode.cpp, geometryCacheConverter.cpp, geometrySurfaceConstraint.cpp, geometrySurfaceConstraint.h, geomShader.cpp, getAttrAffectsCmd.cpp, getPointAndNormal.cpp, getPointAndNormal.h, hairCollisionSolver.cpp, helix2Cmd.cpp, helixTool.cpp, hlslPluginMain.cpp, hlslShader.cpp, hlslShader.h, hwAnisotropicShader_NV20.cpp, hwAnisotropicShader_NV20.h, hwColorPerVertexShader.cpp, hwDecalBumpShader_NV20.cpp, hwDecalBumpShader_NV20.h, hwManagedTextureShader.cpp, hwPhongShader.cpp, hwPhongShader.h, hwPhongShaderBehavior.cpp, hwPhongShaderBehavior.h, hwReflectBumpShader_NV20.cpp, hwReflectBumpShader_NV20.h, hwRefractReflectShader_NV20.cpp, hwRefractReflectShader_NV20.h, hwRenderPostEffect.cpp, hwToonShader_NV20.cpp, hwToonShader_NV20.h, hwUnlitShader.cpp, hwUnlitShader.h, iffInfoCmd.cpp, iffPixelCmd.cpp, iffPpmCmd.cpp, instanceCallbackCmd.cpp, instancerListCmd.cpp, interpShader.cpp, intersectCmd.cpp, intersectOnNurbsSurfaceCmd.cpp, jitterNode.cpp, jlcVcrDevice.cpp, lambertShader.cpp, lassoTool.cpp, latticeNoise.cpp, latticeNoise.h, latticeNoiseCmd.cpp, latticeNoiseNode.cpp, lavaShader.cpp, lepTranslator.cpp, lightShader.cpp, lineManip.cpp, lineManipContainer.cpp, lineManipContainer.h, listLightLinksCmd.cpp, listPolyHolesCmd.cpp, lockEvent.cpp, marqueeTool.cpp, maTranslator.cpp, meshOpCmd.cpp, meshOpCmd.h, meshOpFty.cpp, meshOpFty.h, meshOpMain.cpp, meshOpNode.cpp, meshOpNode.h, meshRemapTool.cpp, meshReorderPlugin.cpp, meshReorderTool.cpp, mixtureShader.cpp, motionPathCmd.cpp, motionTraceCmd.cpp, moveCurveCVsCmd.cpp, moveManip.cpp, moveNumericTool.cpp, moveTool.cpp, MTextureCache.cpp, MTextureCache.h, multiCurveNode.cpp, narrowPolyViewer.h, narrowPolyViewerCmd.h, narrowPolyViewerMain.cpp, nodeCreatedCBCmd.cpp, nodeCreatedCBCmd.h, nodeInfoCmd.cpp, nodeMessageCmd.cpp, NodeMonitor.cpp, NodeMonitor.h, noiseShader.cpp, objExport.cpp, offsetNode.cpp, OpenEXR.cpp, OpenGLViewportRenderer.cpp, OpenGLViewportRendererPlugin.cpp, ownerEmitter.cpp, particleAttrNode.cpp, particleAttrNode.h, particleAttrNodeMain.cpp, particlePathsCmd.cpp, particleSystemInfoCmd.cpp, peltOverlapCmd.cpp, pfxInfoCmd.cpp, phongShader.cpp, pickCmd.cpp, pluginCallbacks.cpp, pluginMain.cpp, pnTrianglesNode.cpp, pnTrianglesNode.h, pointOnMeshInfoNode.cpp, pointOnMeshInfoNode.h, pointOnMeshInfoPlugin.cpp, pointOnSubdNode.cpp, pointOnSubdNode.h, polyMessageCmd.cpp, polyModifierCmd.cpp, polyModifierCmd.h, polyModifierNode.cpp, polyModifierNode.h, polyPrimitiveCmd.cpp, polyRawExporter.cpp, polyRawExporter.h, polyTrgNode.cpp, polyWriter.cpp, polyWriter.h, polyX3DExporter.cpp, polyX3DExporter.h, progressWindowCmd.cpp, quadricShape.cpp, referenceQueryCmd.cpp, renderAccessNode.cpp, renderViewInteractiveRenderCmd.cpp, renderViewRenderCmd.cpp, renderViewRenderRegionCmd.cpp, rockingTransform.cpp, rockingTransform.h, rockingTransformCheck.cpp, rockingTransformCheckMain.cpp, rockingTransformMain.cpp, rotateManip.cpp, sampleCmd.cpp, sampleParticles.cpp, scanDagCmd.cpp, scanDagSyntax.cpp, ShadingConnection.cpp, ShadingConnection.h, shadowMatteShader.cpp, ShapeMonitor.cpp, ShapeMonitor.h, shellNode.cpp, shiftNode.cpp, simpleEmitter.cpp, simpleFluidEmitter.cpp, simpleFluidEmitter.h, simpleImageFile.cpp, simpleLoftNode.cpp, simpleSolverNode.cpp, simpleSpring.cpp, simpleSpring.h, sineNode.cpp, slopeShader.cpp, slopeShaderBehavior.cpp, slopeShaderBehavior.h, slopeShaderNode.cpp, slopeShaderNode.h, solidCheckerShader.cpp, spiralAnimCurveCmd.cpp, splitUVCmd.cpp, splitUVCmd.h, splitUVFty.cpp, splitUVFty.h, splitUVMain.cpp, splitUVNode.cpp, splitUVNode.h, squareScaleManip.cpp, squareScaleManip.h, squareScaleManipContext.cpp, squareScaleManipContext.h, stringFormatNode.cpp, surfaceBumpManip.cpp, surfaceCreateCmd.cpp, surfaceTwistCmd.cpp, sweptEmitter.cpp, swissArmyManip.cpp, testNobjectNode.cpp, testNobjectNode.h, testNucleusNode.cpp, testNucleusNode.h, tiffFloatReader.cpp, torusField.cpp, torusField.h, transCircleNode.cpp, translateCmd.cpp, undoRedoMsgCmd.cpp, userMsgCmd.cpp, viewCallbackTest.cpp, volumeShader.cpp, weightListNode.cpp, whatisCmd.cpp, XmlGeometryCache.cpp, yTwistNode.cpp, and zoomCameraCmd.cpp.

`#include <MObject.h>`

List of all members.

## Public Member Functions
| MObject ()
| Class Constructor.
| MObject (const MObject &other)
| Class Copy Constructor.
| ~MObject ()
| The class destructor.
bool | hasFn (MFn::Type fs) const
| Determines the whether or not the internal Object is compatible with the given Function Type.
bool | isNull () const
| Determines the whether or not an internal Object exists.
MFn::Type | apiType () const
| Determines the exact type of the Maya internal Object.
const char * | apiTypeStr () const
| Returns a string that gives the object's type is a readable form.
bool | operator== (const MObject &) const
| The comparison operator.
bool | operator!= (const MObject &) const
| The inequality operator.
MObject & | operator= (const MObject &)
| The assignment operator.
## Static Public Attributes
static MObject | kNullObj
| Null Object for use as default argument.
## Friends Search for all occurrences
class | MObjectHandle Search for all occurrences

## 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] | other | MObject 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

Search for all occurrences

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

Parameters:

  [in] | fs | Function Set type

Returns:
  - true Is compatible
  - false Is not compatible

Examples:
  animExportUtil.cpp, closestPointOnCurveCmd.cpp, componentScaleManip.cpp, D3DViewportRenderer.cpp, hwAnisotropicShader_NV20.cpp, hwPhongShaderBehavior.cpp, hwToonShader_NV20.cpp, instanceCallbackCmd.cpp, meshRemapTool.cpp, meshReorderTool.cpp, moveManip.cpp, MTextureCache.cpp, nodeCreatedCBCmd.cpp, NodeMonitor.cpp, pointOnMeshCmd.cpp, rotateManip.cpp, ShadingConnection.cpp, slopeShaderBehavior.cpp, and surfaceBumpManip.cpp.

bool isNull | ( |  | ) | const

Search for all occurrences

Determines the whether or not an internal Object exists.

Returns:
  - true Object does not exist
  - false Object exists

Examples:
  animExportUtil.cpp, animFileExport.cpp, animFileUtils.cpp, apiMeshShape.cpp, apiMeshShapeUI.cpp, apiSimpleShape.cpp, apiSimpleShapeUI.cpp, cgfxAttrDef.cpp, componentScaleManip.cpp, convertEdgesToFacesCmd.cpp, convertVerticesToEdgesCmd.cpp, convertVerticesToFacesCmd.cpp, cvExpandCmd.cpp, cvPosCmd.cpp, dagMessageCmd.cpp, exportJointClusterDataCmd.cpp, findTexturesPerPolygonCmd.cpp, geometrySurfaceConstraint.cpp, lassoTool.cpp, latticeNoiseNode.cpp, moveManip.cpp, objExport.cpp, polyModifierCmd.cpp, rockingTransformCheck.cpp, rotateManip.cpp, shellNode.cpp, slopeShaderBehavior.cpp, spiralAnimCurveCmd.cpp, and surfaceBumpManip.cpp.

MFn::Type apiType | ( |  | ) | const

Search for all occurrences

Determines the exact type of the Maya internal Object.

Returns:
  - Exact type of the Maya internal Object. May be general or specific types of DG Nodes or Attributes.

Examples:
  apiMeshShape.cpp, closestPointCmd.cpp, createClipCmd.cpp, cvPosCmd.cpp, dagPoseInfoCmd.cpp, intersectCmd.cpp, lassoTool.cpp, meshOpCmd.cpp, meshOpNode.cpp, objExport.cpp, splitUVCmd.cpp, and splitUVNode.cpp.

const char * apiTypeStr | ( |  | ) | const

Search for all occurrences

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.

Returns:
  - a string containing the type name of the object

Examples:
  cvPosCmd.cpp, filteredAsciiFile.cpp, lassoTool.cpp, nodeInfoCmd.cpp, and whatisCmd.cpp.

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.

MObject MObject MObject MObject MObject MObject MObject MObject MObject MObject
MObject MObject MObject MObject MObject MObject MObject MObject MObject MObject