C++ API Reference
Macros

Macros

#define DeclareSimpleCommand(_className, _vendor, _version)
 This macro expands to all the code necessary to create an undoable command except for the command's "doIt" method. More...
 
#define DeclareSingle(_fnptr)
 The macro expands to all the code necessary to create a basic non-undoable command that calls "functionPtr" from its doIt method. More...
 
#define CHECK_MSTATUS_AND_RETURN(_status, _retVal)
 Return if status is not MStatus::kSuccess. More...
 
#define CHECK_MSTATUS_AND_RETURN_IT(_status)
 Return if status is not MStatus::kSuccess. More...
 
#define CHECK_MSTATUS(_status)
 Output an error message if status is not kSuccess. More...
 
#define MFAIL(_status)
 True if the status is not MStatus::kSuccess. More...
 

Detailed Description

Macro Definition Documentation

#define DeclareSimpleCommand (   _className,
  _vendor,
  _version 
)

This macro expands to all the code necessary to create an undoable command except for the command's "doIt" method.

This macro expects as arguments the name of the class that will be derived from MPxCommand, the name of the organisation owning this code, and the version number of the plug-in.

In addition to the macro, a method with the following prototype needs to be implemented.

1 MStatus className::doIt( const MArgList& )

The macro will generate a class with the given classname that is derived from MPxCommand. It will also generate the following methods:

1 void* className::creator()
2 MStatus initializePlugin( MObject )
3 MStatus uninitializePlugin( MObject )

All methods inherited from MPxCommand such as setResult, displayWarning, and displayError are available.

Parameters
[in]_classNameName of the class
[in]_vendorName of the organisation owning this command
[in]_versionPlug-in version number
Examples:
cvExpandCmd/cvExpandCmd.cpp, findFileTexturesCmd/findFileTexturesCmd.cpp, findTexturesPerPolygonCmd/findTexturesPerPolygonCmd.cpp, getAttrAffectsCmd/getAttrAffectsCmd.cpp, helixCmd/helixCmd.cpp, helloCmd/helloCmd.cpp, helloWorldCmd/helloWorldCmd.cpp, instancerListCmd/instancerListCmd.cpp, listLightLinksCmd/listLightLinksCmd.cpp, listPolyHolesCmd/listPolyHolesCmd.cpp, threadedBoundingBox/threadedBoundingBox.cpp, threadingLockTests/threadingLockTests.cpp, threadTestCmd/threadTestCmd.cpp, threadTestWithLocksCmd/threadTestWithLocksCmd.cpp, viewCaptureCmd/viewCaptureCmd.cpp, volumeLightCmd/volumeLightCmd.cpp, and whatisCmd/whatisCmd.cpp.
#define DeclareSingle (   _fnptr)

The macro expands to all the code necessary to create a basic non-undoable command that calls "functionPtr" from its doIt method.

One limitation of using this macro is that since "functionPtr" is not a member of the class derived from MPxCommand, it cannot call methods (like setResult) that are inherited from that class.

This macro requires as argument a function with the prototype:

1 MStatus functionPtr ( const MArgList& )

The macro will generate a class called _DoItCmd which is derived from MPxCommand. It also generate the following methods:

1 void* _DoItCmd::creator()
2 MStatus _DoItCmd::doIt( const MArgList& args )
3 MStatus initializePlugin( MObject )
4 MStatus uninitializePlugin( MObject )
Parameters
[in]_fnptrCommand function pointer
#define CHECK_MSTATUS_AND_RETURN (   _status,
  _retVal 
)

Return if status is not MStatus::kSuccess.

Output an error message and returns the value 'retVal' if status is not kSuccess.

Parameters
[in]_statusThe status code.
[in]_retValReturn value when status if not kSuccess.
Examples:
flipUVCmd/flipUVCmd.cpp, hairCollisionSolver/hairCollisionSolver.cpp, renderViewInteractiveRenderCmd/renderViewInteractiveRenderCmd.cpp, renderViewRenderCmd/renderViewRenderCmd.cpp, and renderViewRenderRegionCmd/renderViewRenderRegionCmd.cpp.
#define CHECK_MSTATUS (   _status)

Output an error message if status is not kSuccess.

Parameters
[in]_statusThe status code.
Examples:
affectsNode/affectsNode.cpp, anisotropicShader/anisotropicShader.cpp, apiDirectionalLightShape/apiDirectionalLightShape.cpp, apiMeshShape/apiMeshCreator.cpp, backfillShader/backfillShader.cpp, brickShader/brickShader.cpp, cellShader/cellShader.cpp, cgFx/pluginMain.cpp, checkerShader/checkerShader.cpp, circleNode/circleNode.cpp, clearcoat.cpp, compositingShader/compositingShader.cpp, contrastShader/contrastShader.cpp, ddsFloatReader.cpp, depthShader/depthShader.cpp, displacementShader/displacementShader.cpp, dx11Shader/dx11ShaderPluginMain.cpp, fileTexture/fileTexture.cpp, flameShader/flameShader.cpp, gameInputDevice/gameInputDevice.cpp, gammaShader/gammaShader.cpp, genericAttributeNode/genericAttributeNode.cpp, geometrytools.cpp, geomShader/geomShader.cpp, glslShader/GLSLShaderMainMaya.cpp, hairCollisionSolver/hairCollisionSolver.cpp, hlslShader/hlslPluginMain.cpp, interpShader/interpShader.cpp, lambertShader/lambertShader.cpp, lavaShader/lavaShader.cpp, lightShader/lightShader.cpp, mixtureShader/mixtureShader.cpp, multiCurveNode/multiCurveNode.cpp, noiseShader/noiseShader.cpp, onbShader/onbShader.cpp, OpenEXR.cpp, phongShader/phongShader.cpp, pointOnMeshInfo/pointOnMeshInfoNode.cpp, progressWindowCmd/progressWindowCmd.cpp, renderAccessNode/renderAccessNode.cpp, sceneAssembly/assemblyDefinition.cpp, sceneAssembly/assemblyReference.cpp, simpleImageFile/simpleImageFile.cpp, simpleNoiseShader/simpleNoiseShader.cpp, stringFormatNode/stringFormatNode.cpp, tiffFloatReader.cpp, topologyTrackingNode/topologyTrackingNode.cpp, and volumeShader/volumeShader.cpp.
#define MFAIL (   _status)

True if the status is not MStatus::kSuccess.

Parameters
[in]_statusThe status code.