Public Types | Public Member Functions | Protected Member Functions

MPxConstraintCommand Class Reference

This reference page is linked to from the following overview topics: MPxNode and its derived classes, Removal of MStatus return codes from .NET API, Example C++ plug-in descriptions.


Search for all occurrences

Detailed Description

Proxy constraint command.

MPxConstraintCommand is the base class for user defined constraint commands. This command gives all of the flags and options of the base constraint command in addition allows user defined flags or behaviours. When registering this command, use the MFnPlugin::registerConstraintCommand() method. A MPxConstraint is also required to be used with MPxConstraintCommand. The constraintTypeId() virtual must be implemented to return the correct constraint node.

Examples:

geometrySurfaceConstraint.h.

#include <MPxConstraintCommand.h>

Inheritance diagram for MPxConstraintCommand:
Inheritance graph
[legend]

List of all members.

Public Types

enum  TargetType { kTransform, kGeometryShape, kLast }
 

Defines the type of target object.

More...

Public Member Functions

 MPxConstraintCommand ()
 Constructor.
virtual ~MPxConstraintCommand ()
 Destructor.
virtual MStatus doIt (const MArgList &argList)
 This method should execute a command by setting up internal class data and then return control to Maya for executing the base constraint command functionality.
virtual MStatus undoIt ()
 This method should undo the work done be the redoIt method based on the internal class data only.
virtual MStatus redoIt ()
 This method should do the actual work of the command based on the internal class data only.
virtual MStatus appendSyntax ()
 This method should be overridden to append syntax to the constraint command.

Protected Member Functions

virtual MStatus parseArgs (const MArgList &argList)
 This method is used for parsing any custom flags/params that have been added to the command.
MSyntax syntax (MStatus *ReturnStatus=NULL) const
 USE _syntax() IN SCRIPT.
virtual MStatus doEdit ()
 This method is used for editing any custom setting on the command.
virtual MStatus doCreate ()
 This method is used for creating resources required by the command.
virtual MStatus doQuery ()
 This method is used for querying information defined in the command.
virtual void createdConstraint (MPxConstraint *constraint)
 This method is called when an MPxConstraintCommand creates a new MPxConstraint node.
virtual bool supportsOffset () const
 This method is used to control if the constraint supports offset.
virtual bool hasVectorFlags () const
 This method is used to control if the constraint supports the base class vector flags.
virtual MTypeId constraintTypeId () const
 This method is used to return the MTypeId of the MPxConstraint node that is used with this command.
virtual
MPxConstraintCommand::TargetType 
targetType () const
 Maya supports constraints targets which are either transforms or nodes derived from "geometryShape".
virtual const MObjectaimVectorAttribute () const
 This method returns an attribute which defines the aim vector of a constraint.
virtual const MObjectupVectorAttribute () const
 This method returns an upVector attribute that is used in conjunction with the aimVector.
virtual const MObjectworldUpMatrixAttribute () const
 This method returns an worldUpMatrix attribute that is used in conjunction with the aimVector.
virtual const MObjectworldUpTypeAttribute () const
 This method returns an worldUpType attribute that is used in conjunction with the aimVector.
virtual const MObjectworldUpVectorAttribute () const
 This method returns an worldUpVector attribute that is used in conjunction with the aimVector.
virtual const MObjectoffsetAttribute () const
 This method returns the offset attribute and must be implemented if supportsOffset() returns true.
virtual const MObjectconstraintInstancedAttribute () const
 This method returns the attribute on the constraint node that connects to an instanced constraint attribute of the constrained object.
virtual const MObjectconstraintOutputAttribute () const
 This method returns the attribute this constraint will connect to the constrained attribute of the constrained object.
virtual const MObjectconstraintRestAttribute () const
 This method returns the rest state attribute for the constraint.
virtual const MObjectconstraintEnableRestAttribute () const
 This method returns the constraintReset attribute for the constraint.
virtual const MObjectconstraintTargetInstancedAttribute () const
 This method returns the constraintTargetInstanced attribute for the constraint.
virtual const MObjectconstraintTargetAttribute () const
 This method returns the constraintTarget attribute for the constraint.
virtual const MObjectconstraintTargetWeightAttribute () const
 This method returns the constraintTargetWeight attribute for the constraint.
virtual const MObjectobjectAttribute () const
 This method returns the attribute this constraint will drive on the constrained object.
virtual void getObjectAttributesArray (MObjectArray &array)
 This method returns the list of attributes this particular constraint considers when inserting a pair blend.
virtual void handleNewTargets (MObject &dagObject)
 This method is obsolete. This method is not available in Python.
virtual MStatus handleNewTargets (MDagPath &dagObject)
 This method is used to perform any special processing when targets are added to the constraint.
virtual MStatus connectTarget (void *opaqueTarget, int index)
 This method is obsolete. This method is not available in Python.
virtual MStatus connectTarget (MDagPath &targetPath, int index)
 This method is called to make connections between the constraint and the target.
virtual MStatus connectObjectAndConstraint (MDGModifier &modifier)
 This method is used for connecting the constraint and constrained object.
MStatus connectGeometryAttribute (void *opaqueTarget, int index, MObject &constraintAttr)
 Utility method to make any required connections for the constraint.
MStatus connectTargetAttribute (void *opaqueTarget, int index, MObject &constraintAttr)
 This method is obsolete. This method is not available in Python.
MStatus connectTargetAttribute (MDagPath &targetPath, int index, MObject &tarAttr, MObject &constraintAttr, bool instanced=false)
 Utility method to make any required connections for the constraint.
MStatus connectObjectAttribute (const MObject &objectAttr, const MObject &constraintAttr, bool toConstraint=true, bool instanced=false)
 This method can be used by connectObjectAndConstraint() to make any required connections between the constraint and the constrained object.
const MObject transformObject ()
 This method returns the target object being constrained.

Member Enumeration Documentation

enum TargetType

Defines the type of target object.

Enumerator:
kTransform 

Transform target.

kGeometryShape 

Geometry shape(or children of) targets.

kLast 

Last value, used for counting.


Constructor & Destructor Documentation

~MPxConstraintCommand ( ) [virtual]

Destructor.

Local class data should be freed here.


Member Function Documentation

MStatus doIt ( const MArgList args) [virtual]

This method should execute a command by setting up internal class data and then return control to Maya for executing the base constraint command functionality.

This is a virtual, and can be overridden in derived classes.

Default behaviour returns MS::kUnknownParameter so that Maya handles the operation.

Parameters:
[in]argsthe command's argument list.
Returns:
Status code
Status Codes:

Reimplemented from MPxCommand.

Examples:
geometrySurfaceConstraint.h.
MStatus undoIt ( ) [virtual]

This method should undo the work done be the redoIt method based on the internal class data only.

Default behaviour returns MS::kUnknownParameter so that Maya handles the operation.

Returns:
Status code
Status Codes:

Reimplemented from MPxCommand.

MStatus redoIt ( ) [virtual]

This method should do the actual work of the command based on the internal class data only.

Internal class data should be set in the doIt method.

Default behaviour returns MS::kUnknownParameter so that Maya handles the operation.

Returns:
Status code
Status Codes:

Reimplemented from MPxCommand.

MStatus appendSyntax ( ) [virtual]

This method should be overridden to append syntax to the constraint command.

The syntax object can be obtained by calling the syntax method. The following flags cannot be used as user-defined flags as they are reserved for edit and query: "-e", "-edit", "-q", "-query".

Standard constraint flags that are provided are: name "-n" "-name", weight "-w" "-weight", target list "-tl" "-targetList", remove "-rm" "-remove", target alias "-wal" "-weightAliasList".

Returns:
Examples:
geometrySurfaceConstraint.h.
MStatus parseArgs ( const MArgList argList) [protected, virtual]

This method is used for parsing any custom flags/params that have been added to the command.

Return MS::kUnknownParameter to allow the processing of base flags/params.

Default behaviour returns MS::kUnknownParameter so that Maya handles the operation.

Parameters:
[in]argListthe command's argument list.
Returns:
Status code
Status Codes:
Examples:
geometrySurfaceConstraint.h.
MSyntax syntax ( MStatus ReturnStatus = NULL) const [protected]

USE _syntax() IN SCRIPT.

This method returns the syntax object of this constraint command.

The syntax object can be appended to in an overridden version of the appendSyntax method.

Parameters:
[out]ReturnStatusreturn status
Returns:
  • the syntax object
Status Codes:
MStatus doEdit ( ) [protected, virtual]

This method is used for editing any custom setting on the command.

Return MS::kUnknownParameter to allow processing of the base class functionality.

Default behaviour returns MS::kUnknownParameter so that Maya handles the operation.

Returns:
Status code
Status Codes:
MStatus doCreate ( ) [protected, virtual]

This method is used for creating resources required by the command.

Return MS:kUnknownParameter to allow processing of base class functionality.

Default behaviour returns MS::kUnknownParameter so that Maya handles the operation.

Returns:
Status code
Status Codes:
MStatus doQuery ( ) [protected, virtual]

This method is used for querying information defined in the command.

Return MS:kUnknownParameter to allow processing of base class functionality.

Default behaviour returns MS::kUnknownParameter so that Maya handles the operation.

Returns:
Status code
Status Codes:
void createdConstraint ( MPxConstraint constraint) [protected, virtual]

This method is called when an MPxConstraintCommand creates a new MPxConstraint node.

It can be used for transferring state from the command to the node object.

Parameters:
[in]constraintthe constraint node created by the command.
Examples:
geometrySurfaceConstraint.h.
bool supportsOffset ( ) const [protected, virtual]

This method is used to control if the constraint supports offset.

Return true if the constraint should support offset. False is returned otherwise and is the default behaviour of this method.

If this method returns true, then the offsetAttribute() method should return a 3 double attribute.

bool hasVectorFlags ( ) const [protected, virtual]

This method is used to control if the constraint supports the base class vector flags.

Return true if the constraint should support the vector flags. False is returned otherwise and is the default behaviour of this method.

If this method returns true, then the following methods need to return valid attributes: aimVectorAttribute(), upVectorAttribute() worldUpMatrixAttribute(), worldUpTypeAttribute(), worldUpVectorAttribute().

MTypeId constraintTypeId ( ) const [protected, virtual]

This method is used to return the MTypeId of the MPxConstraint node that is used with this command.

This virtual must be implemented in a proxy constraint command.

This method must be implemented.

Examples:
geometrySurfaceConstraint.h.
MPxConstraintCommand::TargetType targetType ( ) const [protected, virtual]

Maya supports constraints targets which are either transforms or nodes derived from "geometryShape".

Return the appropriate target type in this method.

By default, this method returns MPxConstraintCommand::kTransform.

Examples:
geometrySurfaceConstraint.h.
const MObject & aimVectorAttribute ( ) const [protected, virtual]

This method returns an attribute which defines the aim vector of a constraint.

The aimVector attribute defines a vector in the space of the constrained object that should be aligned with the weighted average vector computed by the constraint. The upVectorAttribute(), worldUpVectorAttribute(), worldUpMatrixAttribute, and worldUpTypeAttribute() define how the constrained object is rotated about the aimVector.

The aimVector returned should be a 3 double attribute.

The default behaviour of the method is to return a MObject::kNullObj.

const MObject & upVectorAttribute ( ) const [protected, virtual]

This method returns an upVector attribute that is used in conjunction with the aimVector.

The upVector returned should be a 3 double attribute.

The default behaviour of the method is to return a MObject::kNullObj.

const MObject & worldUpMatrixAttribute ( ) const [protected, virtual]

This method returns an worldUpMatrix attribute that is used in conjunction with the aimVector.

The worldUpMatrix returned should be a matrix attribute.

The default behaviour of the method is to return a MObject::kNullObj.

const MObject & worldUpTypeAttribute ( ) const [protected, virtual]

This method returns an worldUpType attribute that is used in conjunction with the aimVector.

The worldUpType returned should be a enum attribute.

The default behaviour of the method is to return a MObject::kNullObj.

const MObject & worldUpVectorAttribute ( ) const [protected, virtual]

This method returns an worldUpVector attribute that is used in conjunction with the aimVector.

The worldUpVector returned should be a 3 double attribute.

The default behaviour of the method is to return a MObject::kNullObj.

const MObject & offsetAttribute ( ) const [protected, virtual]

This method returns the offset attribute and must be implemented if supportsOffset() returns true.

The offset returned should be a 3 double attribute.

The default behaviour of the method is to return a MObject::kNullObj.

const MObject & constraintInstancedAttribute ( ) const [protected, virtual]

This method returns the attribute on the constraint node that connects to an instanced constraint attribute of the constrained object.

The type of the attribute will depend on the constraint implementation.

The default behaviour of the method is to return a MObject::kNullObj.

Examples:
geometrySurfaceConstraint.h.
const MObject & constraintOutputAttribute ( ) const [protected, virtual]

This method returns the attribute this constraint will connect to the constrained attribute of the constrained object.

The type of the attribute will depend on the constraint implementation.

The default behaviour of the method is to return a MObject::kNullObj.

Examples:
geometrySurfaceConstraint.h.
const MObject & constraintRestAttribute ( ) const [protected, virtual]

This method returns the rest state attribute for the constraint.

Constraints supporting rest state should implement this method.

The constraintReset attribute is a 3 double.

The default behaviour of the method is to return a MObject::kNullObj.

const MObject & constraintEnableRestAttribute ( ) const [protected, virtual]

This method returns the constraintReset attribute for the constraint.

The constraintReset attribute is a boolean.

The default behaviour of the method is to return a MObject::kNullObj.

const MObject & constraintTargetInstancedAttribute ( ) const [protected, virtual]

This method returns the constraintTargetInstanced attribute for the constraint.

The type of the attribute will depend on the constraint implementation. Suggested attribute types include a parent matrix or target geometry.

The default behaviour of the method is to return a MObject::kNullObj.

Examples:
geometrySurfaceConstraint.h.
const MObject & constraintTargetAttribute ( ) const [protected, virtual]

This method returns the constraintTarget attribute for the constraint.

The type of the attribute will depend on the constraint implementation. But it must be an compound array attribute.

The default behaviour of the method is to return a MObject::kNullObj.

Examples:
geometrySurfaceConstraint.h.
const MObject & constraintTargetWeightAttribute ( ) const [protected, virtual]

This method returns the constraintTargetWeight attribute for the constraint.

The type of the constraintTargetWeight attribute is a double.

The default behaviour of the method is to return a MObject::kNullObj.

Examples:
geometrySurfaceConstraint.h.
const MObject & objectAttribute ( ) const [protected, virtual]

This method returns the attribute this constraint will drive on the constrained object.

The default behaviour of the method is to return a MObject::kNullObj.

Examples:
geometrySurfaceConstraint.h.
void getObjectAttributesArray ( MObjectArray array) [protected, virtual]

This method returns the list of attributes this particular constraint considers when inserting a pair blend.

Parameters:
[in]arrayArray of attributes.
void handleNewTargets ( MObject dagObject) [protected, virtual]

This method is obsolete. This method is not available in Python.

Deprecated:
Use MPxConstraintCommand::handleNewTargets( MDagpath& dagObject ) instead.
Parameters:
[in]dagObject
MStatus handleNewTargets ( MDagPath dagObject) [protected, virtual]

This method is used to perform any special processing when targets are added to the constraint.

For example, the constraint may need to keep track of the list of targets to properly calculate an offset.

Parameters:
[in]dagObjectpath to the new constraint target
MStatus connectTarget ( void *  opaqueTarget,
int  index 
) [protected, virtual]

This method is obsolete. This method is not available in Python.

Deprecated:
Use MPxConstraintCommand::connectTarget(MDagPath &targetPath, int index) instead.
Parameters:
[in]opaqueTarget
[in]index
Examples:
geometrySurfaceConstraint.h.
MStatus connectTarget ( MDagPath targetPath,
int  index 
) [protected, virtual]

This method is called to make connections between the constraint and the target.

Since the default behaviour is to do nothing it is generally necessary to override this method if your constraint is to work properly. The connectTargetAttribute() convenience method can be useful in this regard.

Default behaviour makes no connections.

Parameters:
[in]targetPathDAG path of the target
[in]indexindex for this target in the node's constraint target attribute
Returns:
Status code
Status Codes:
MStatus connectObjectAndConstraint ( MDGModifier modifier) [protected, virtual]

This method is used for connecting the constraint and constrained object.

The utility method MPxConstraintCommand::connectObjectAttribute() is used to connect the attributes.

Default behaviour returns MS::kUnknownParameter so that Maya handles the operation.

Parameters:
[in]modifierused for setting plug values such as translation
Returns:
Status code
Status Codes:
Examples:
geometrySurfaceConstraint.h.
MStatus connectGeometryAttribute ( void *  opaqueTarget,
int  index,
MObject constraintAttribute 
) [protected]

Utility method to make any required connections for the constraint.

Note that it is called by the default implementation of connectTarget().

Parameters:
[in]opaqueTargetas passed to connectTarget()
[in]indexas passed to connectTarget()
[in]constraintAttributeas defined by the constraint
Returns:
Status code
Status Codes:
MStatus connectTargetAttribute ( void *  opaqueTarget,
int  index,
MObject constraintAttribute 
) [protected]

This method is obsolete. This method is not available in Python.

Deprecated:
Use MPxConstraintCommand::connectTargetAttribute(MDagPath &targetPath, int index) instead.
Parameters:
[in]opaqueTarget
[in]index
[in]constraintAttribute
MStatus connectTargetAttribute ( MDagPath targetPath,
int  index,
MObject targetAttribute,
MObject constraintAttr,
bool  instanced = false 
) [protected]

Utility method to make any required connections for the constraint.

Parameters:
[in]targetPathas passed to connectTarget()
[in]indexas passed to connectTarget()
[in]targetAttributeas defined by the target
[in]constraintAttras defined by the constraint
[in]instancedtrue if targetAttribute is an instanced attribute
Returns:
Status code
Status Codes:
MStatus connectObjectAttribute ( const MObject objectAttr,
const MObject constraintAttr,
bool  toConstraint = true,
bool  instanced = false 
) [protected]

This method can be used by connectObjectAndConstraint() to make any required connections between the constraint and the constrained object.

Parameters:
[in]objectAttras passed to connectTarget()
[in]constraintAttras defined by the constraint
[in]toConstrainttrue if connection is from object to constraint, false if connection is from constraint to object
[in]instancedtrue if objectAttr must be indexed by instance number
Returns:
Status code
Status Codes:
const MObject transformObject ( ) [protected]

This method returns the target object being constrained.

The object returned will be a "transform" node. This node can be queried using MFnTransform to extract information such as translate, scale etc which will allow the placement of the constrained object in a reasonable default location. For example, a geometric constraint may wish to place the constrained object on top of the target.


MPxConstraintCommand MPxConstraintCommand MPxConstraintCommand MPxConstraintCommand MPxConstraintCommand MPxConstraintCommand MPxConstraintCommand MPxConstraintCommand MPxConstraintCommand MPxConstraintCommand
MPxConstraintCommand MPxConstraintCommand MPxConstraintCommand MPxConstraintCommand MPxConstraintCommand MPxConstraintCommand MPxConstraintCommand MPxConstraintCommand MPxConstraintCommand MPxConstraintCommand