MPxConstraintCommand Class Reference

+ この参照ページは、次の概要トピックと関連付けられています。

#include <MPxConstraintCommand.h>

Class 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:
+ Inheritance diagram for MPxConstraintCommand:

Public Types

enum  TargetType { kTransform, kGeometryShape, kLast }
 Defines the type of target object. More...
 
- Public Types inherited from MPxCommand
enum  MResultType { kLong, kDouble, kString, kNoArg }
 Types of results from commands. More...
 

Public Member Functions

 MPxConstraintCommand ()
 Constructor.
 
virtual ~MPxConstraintCommand ()
 Destructor. More...
 
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. More...
 
virtual MStatus undoIt ()
 This method should undo the work done be the redoIt method based on the internal class data only. More...
 
virtual MStatus redoIt ()
 This method should do the actual work of the command based on the internal class data only. More...
 
virtual MStatus appendSyntax ()
 This method should be overridden to append syntax to the constraint command. More...
 
- Public Member Functions inherited from MPxCommand
 MPxCommand ()
 Constructor.
 
virtual ~MPxCommand ()
 Destructor. More...
 
virtual bool isUndoable () const
 This method is used to specify whether or not the command is undoable. More...
 
virtual bool hasSyntax () const
 This method specifies whether or not the command has a syntax object. More...
 
MSyntax syntax () const
 This method is intended to be used in an MArgDataBase or MArgParser contructor when the plugin command's syntax is being initialized. More...
 
bool isHistoryOn () const
 Returns whether history is on. More...
 
MString commandString () const
 This method returns the command string that is associated with this command. More...
 
MStatus setHistoryOn (bool state)
 This method specifies if history for this command is on. More...
 
MStatus setCommandString (const MString &)
 Sets the command string that is associated with this command object. More...
 
MStatus setUndoable (bool state)
 This method is obsolete. More...
 

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

Additional Inherited Members

- Static Public Member Functions inherited from MPxCommand
static void displayInfo (const MString &theInfo)
 This method is used to display information in the script editor. More...
 
static void displayWarning (const MString &theWarning, bool showLineNumber=false)
 This method is used to display a warning in the script editor. More...
 
static void displayError (const MString &theError, bool showLineNumber=false)
 This method is used to display an error in the script editor. More...
 
static void clearResult ()
 Initializes the place where results from Maya commands get stored.
 
static void setResult (unsigned int val)
 This method puts the given value into the return value area for a command. More...
 
static void setResult (int val)
 This method puts the given value into the return value area for a command. More...
 
static void setResult (double val)
 This method puts the given value into the return value area for a command. More...
 
static void setResult (bool val)
 This method puts the given value into the return value area for a command. More...
 
static void setResult (const char *val)
 This method puts the given value into the return value area for a command. More...
 
static void setResult (const MString &val)
 This method puts the given value into the return value area for a command. More...
 
static void setResult (const MIntArray &val)
 This method puts the given values into the return value area for a command. More...
 
static void setResult (const MDoubleArray &val)
 This method puts the given values into the return value area for a command. More...
 
static void setResult (const MStringArray &val)
 This method puts the given values into the return value area for a command. More...
 
static void appendToResult (int val)
 This method will add the given value to the end of the result array of integers. More...
 
static void appendToResult (double val)
 This method will add the given value to the end of the result array of doubles. More...
 
static void appendToResult (bool val)
 This method will add the given value to the end of the result array of integers. More...
 
static void appendToResult (const char *val)
 This method will add the given value to the end of the result array of strings. More...
 
static void appendToResult (const MString &val)
 This method will add the given value to the end of the result array of strings. More...
 
static void appendToResult (const MStringArray &val)
 This method will add the given value to the end of the result array of strings. More...
 
static bool isCurrentResultArray ()
 This method will return whether the return result for the command is an array or not. More...
 
static MResultType currentResultType ()
 This method will return the type of the current result for the command. More...
 
static MStatus getCurrentResult (int &val)
 This method is not available in Python. More...
 
static MStatus getCurrentResult (double &val)
 This method is not available in Python. More...
 
static MStatus getCurrentResult (MString &val)
 This method is not available in Python. More...
 
static MStatus getCurrentResult (MIntArray &val)
 This method gets the current node's result as an array of integers, if possible. More...
 
static MStatus getCurrentResult (MDoubleArray &val)
 This method gets the current node's result as an array of doubles, if possible. More...
 
static MStatus getCurrentResult (MStringArray &val)
 This method gets the current node's result as an array of strings, if possible. More...
 
static int currentIntResult (MStatus *ReturnStatus=NULL)
 This method gets the current node's result as a int, if possible. More...
 
static double currentDoubleResult (MStatus *ReturnStatus=NULL)
 This method gets the current node's result as a double, if possible. More...
 
static MString currentStringResult (MStatus *ReturnStatus=NULL)
 This method gets the current node's result as a MString, if possible. More...
 
static const char * className ()
 Returns the name of this class. More...
 

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:
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:
MStatus parseArgs ( const MArgList argList)
protectedvirtual

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:
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 ( )
protectedvirtual

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 ( )
protectedvirtual

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 ( )
protectedvirtual

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)
protectedvirtual

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:
bool supportsOffset ( ) const
protectedvirtual

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
protectedvirtual

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
protectedvirtual

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:
MPxConstraintCommand::TargetType targetType ( ) const
protectedvirtual

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:
const MObject & aimVectorAttribute ( ) const
protectedvirtual

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
protectedvirtual

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
protectedvirtual

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
protectedvirtual

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
protectedvirtual

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
protectedvirtual

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
protectedvirtual

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:
const MObject & constraintOutputAttribute ( ) const
protectedvirtual

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:
const MObject & constraintRestAttribute ( ) const
protectedvirtual

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
protectedvirtual

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
protectedvirtual

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:
const MObject & constraintTargetAttribute ( ) const
protectedvirtual

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:
const MObject & constraintTargetWeightAttribute ( ) const
protectedvirtual

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:
const MObject & objectAttribute ( ) const
protectedvirtual

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:
void getObjectAttributesArray ( MObjectArray array)
protectedvirtual

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)
protectedvirtual

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)
protectedvirtual

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 
)
protectedvirtual

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:
MStatus connectTarget ( MDagPath targetPath,
int  index 
)
protectedvirtual

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)
protectedvirtual

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:
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.


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