C++ API Reference
MPxConstraintCommand Class Reference

Proxy constraint command. More...

#include <MPxConstraintCommand.h>

+ 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.
 
 ~MPxConstraintCommand () override
 Destructor. More...
 
MStatus doIt (const MArgList &argList) override
 This virtual method is called when the command is intially executed (i.e. More...
 
MStatus undoIt () override
 This virtual method is called when the command is being undone. More...
 
MStatus redoIt () override
 This virtual method is called when the command is being redone. More...
 
virtual MStatus appendSyntax ()
 This method should be overridden to append syntax to the constraint command. More...
 
MPxConstraintconstraintNode ()
 Returns the custom MPxConstraint-derived node created by this instance of the 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 virtual method is called by the default behaviour of doIt() to parse the command's arguments. More...
 
MSyntax syntax (MStatus *ReturnStatus=NULL) const
 USE _syntax() IN PYTHON. More...
 
virtual MStatus doEdit ()
 This virtual method is called by the default behaviour of doIt() if the command was executed in create or edit mode (i.e. More...
 
virtual MStatus doCreate ()
 This virtual method is called by the default behaviour of doIt() when the command is being executed in create mode. More...
 
virtual MStatus doQuery ()
 This virtual method is called by the default behaviour of doIt() when the command is being executed in query mode. 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 attribute used to store the constraint's rest state. More...
 
virtual const MObjectconstraintEnableRestAttribute () const
 This method returns the attribute used to enable and disable the rest state at runtime. 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. 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. 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...
 
virtual MStatus setRestPosition (MDGModifier &modifier)
 Override this method if you want to control the value to which the constraint node's rest position attribute (i.e. 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. 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...
 

Detailed Description

Proxy constraint command.

MPxConstraintCommand is the base class for user defined commands which create constraints. This command gives all of the flags and options of the base constraint command and 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 type id.

Examples:
geometrySurfaceConstraint/geometrySurfaceConstraint.h.

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

Destructor.

Local class data should be freed here.

Member Function Documentation

MStatus doIt ( const MArgList args)
overridevirtual

This virtual method is called when the command is intially executed (i.e.

before any subsequent undo or redo). Normal usage is to do any specialized setup or non-editable flags that your command requires here and then return MS::kUnknownParameter so that Maya will do its default behaviour. However, you can also take complete control of the command by returning MS::kSuccess instead.

On query the default behaviour is to call the following methods:

On create the default behaviour is to call the following methods:

On edit the default behaviour is to call the following methods:

If you do not return MS::kUnknownParameter then none of these methods will be called and you will be responsible for performing the equivalent actions yourself.

Internally Maya uses the equivalent of an MDGModifier to keep track of the changes it makes, for later use in undo/redo. Although this modifier is provided to some of the class's virtual methods, such as setRestPosition(), it is not provided to doIt(), undoIt() or redoIt(). So if you decided to take complete control of one of the three (i.e. by returning MS::kSuccess) then you will need to take full control of all three.

Parameters
[in]argsthe command's argument list.
Returns
Status code
Status Codes:
  • MS::kSuccess The command was successful
  • MS::kFailure An error occurred during the command
  • MS::kUnknownParameter If the method was called by Maya this indicates that Maya should do its default behaviour.

Reimplemented from MPxCommand.

Examples:
geometrySurfaceConstraint/geometrySurfaceConstraint.h.
MStatus undoIt ( )
overridevirtual

This virtual method is called when the command is being undone.

Normal usage is to undo any specialized setup that you did in doIt() and then return MS::kUnknownParameter so that Maya will do its default behaviour.

The default behaviour is to undo the command's internal DG modifier. See doIt() for more details.

Returns
Status code
Status Codes:
  • MS::kSuccess The command was successful
  • MS::kFailure An error occurred during the command
  • MS::kUnknownParameter If the method was called by Maya this indicates that Maya should do its default behaviour.

Reimplemented from MPxCommand.

MStatus redoIt ( )
overridevirtual

This virtual method is called when the command is being redone.

Normal usage is to redo any specialized setup that you did in doIt() and then return MS::kUnknownParameter so that Maya will do its default behaviour.

The default behaviour is to redo the command's internal DG modifier. See doIt() for more details.

Returns
Status code
Status Codes:
  • MS::kSuccess The command was successful
  • MS::kFailure An error occurred during the command
  • MS::kUnknownParameter If the method was called by Maya this indicates that Maya should do its default behaviour.

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
  • MS::kSuccess operation successful
  • MS::kFailure operation failed
Examples:
geometrySurfaceConstraint/geometrySurfaceConstraint.h.
MPxConstraint * constraintNode ( )
inline

Returns the custom MPxConstraint-derived node created by this instance of the command.

This can be useful if the command needs to access methods or members of the node.

Returns
The created node.
MStatus parseArgs ( const MArgList argList)
protectedvirtual

This virtual method is called by the default behaviour of doIt() to parse the command's arguments.

Normal usage is to override this method to parse any flags or command arguments which are specific to your command, and then return MS::kUnknownParameter to have Maya do its default behaviour.

The default behaviour is:

  • Parse flags which are common to all constraints (e.g. -weight)
  • Call hasVectorFlags().
  • If hasVectorFlags() returned true, parse the common vector flags (e.g. -aim) and their related flags (e.g. -worldUpType).
  • Parse the object list.
Parameters
[in]argListthe command's argument list.
Returns
Status code
Status Codes:
  • MS::kSuccess The parseArgs was successful
  • MS::kFailure An error occurred during the parseArgs
  • MS::kUnknownParameter If the method was called by Maya this indicates that Maya should do its default behaviour.
Examples:
geometrySurfaceConstraint/geometrySurfaceConstraint.h.
MSyntax syntax ( MStatus ReturnStatus = NULL) const
protected

USE _syntax() IN PYTHON.

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:
  • MS::kSuccess operation successful
  • MS::kFailure operation failed
MStatus doEdit ( )
protectedvirtual

This virtual method is called by the default behaviour of doIt() if the command was executed in create or edit mode (i.e.

not query). Normal usage is to handle any custom editable flags that your command supports and then return MS::kUnknownParameter so that Maya will do its default behaviour.

If the -remove flag was set, the default behaviour is to disconnect the targets specified on the command line.

If the -remove flag was not set, the default behaviour is:

Returns
Status code
Status Codes:
  • MS::kSuccess The edit was successful
  • MS::kFailure An error occurred during the edit
  • MS::kUnknownParameter If the method was called by Maya this indicates that Maya should do its default behaviour.
MStatus doCreate ( )
protectedvirtual

This virtual method is called by the default behaviour of doIt() when the command is being executed in create mode.

It is not normally useful to override this method since the node will not be created until after the override has returned control to Maya.

The default behaviour is to:

Returns
Status code
Status Codes:
  • MS::kSuccess The create was successful
  • MS::kFailure An error occurred during the create
  • MS::kUnknownParameter If the method was called by Maya this indicates that Maya should do its default behaviour.
MStatus doQuery ( )
protectedvirtual

This virtual method is called by the default behaviour of doIt() when the command is being executed in query mode.

Normal usage is to process the queries for flags which are specific to your command and return MS::kSuccess. If none of your command-specific flags is being queried then return MS::kUnknownParameter so that Maya will handle queries for the standard flags.

The default behaviour is:

  • Call hasVectorFlags().
  • If hasVectorFlags() returned true, check for the common vector flags (e.g. -aim) and their related flags (e.g. -worldUpType) and set the command's result to the corresponding value.
  • Check for the other common constraint flags (e.g. -name) and set the command result to its corresponding value.

If multiple flags are queried only the value of the first one will be set as the command's return value, where "first" refers to the order in which they are checked, not the order in which the appear in the command.

Returns
Status code
Status Codes:
  • MS::kSuccess The query was successful
  • MS::kFailure An error occurred during the query
  • MS::kUnknownParameter If the method was called by Maya this indicates that Maya should do its default behaviour.
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:
geometrySurfaceConstraint/geometrySurfaceConstraint.h.
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() and constraintOutputAttribute() methods should both return attributes of type MFnNumericData::k3Double. If constraintRestAttribute() returns an attribute it should be k3Double as well.

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:
geometrySurfaceConstraint/geometrySurfaceConstraint.h.
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:
geometrySurfaceConstraint/geometrySurfaceConstraint.h.
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 type of the returned attribute must be MFnNumericData::k3Double.

The default behaviour of the method is to return a MObject::kNullObj (i.e. no attribute).

const MObject & upVectorAttribute ( ) const
protectedvirtual

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

The type of the returned attribute must be MFnNumericData::k3Double.

The default behaviour of the method is to return a MObject::kNullObj (i.e. no attribute).

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 (i.e. no attribute).

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 (i.e. no attribute).

const MObject & worldUpVectorAttribute ( ) const
protectedvirtual

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

The type of the returned attribute must be MFnNumericData::k3Double.

The default behaviour of the method is to return a MObject::kNullObj (i.e. no attribute).

const MObject & offsetAttribute ( ) const
protectedvirtual

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

The type of the returned attribute must be MFnNumericData::k3Double.

The default behaviour of the method is to return a MObject::kNullObj (i.e. no attribute).

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 (i.e. no attribute).

Examples:
geometrySurfaceConstraint/geometrySurfaceConstraint.h.
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. Normally this is an MFnNumericData::k3Double attribute. To support an output attribute of any other type, you must do the following:

The default behaviour of the method is to return MObject::kNullObj (i.e. no attribute).

Examples:
geometrySurfaceConstraint/geometrySurfaceConstraint.h.
const MObject & constraintRestAttribute ( ) const
protectedvirtual

This method returns the attribute used to store the constraint's rest state.

Constraints supporting rest state should implement this method.

Usually the type of this attribute is MFnNumericData::k3Double. If you return an attribute with any other type then you will have to override setRestPosition() to handle it properly.

The default behaviour of the method is to return a MObject::kNullObj (i.e. no attribute).

const MObject & constraintEnableRestAttribute ( ) const
protectedvirtual

This method returns the attribute used to enable and disable the rest state at runtime.

Constraints supporting rest state should implement this method.

The constraintRest attribute is a boolean.

The default behaviour of the method is to return a MObject::kNullObj (i.e no attribute).

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 (i.e. no attribute).

Examples:
geometrySurfaceConstraint/geometrySurfaceConstraint.h.
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 (i.e. no attribute).

Examples:
geometrySurfaceConstraint/geometrySurfaceConstraint.h.
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 (i.e. no attribute).

Examples:
geometrySurfaceConstraint/geometrySurfaceConstraint.h.
const MObject & objectAttribute ( ) const
protectedvirtual

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

The type of the returned attribute must be the same as that returned by constraintOutputAttribute().

The default behaviour of the method is to return a MObject::kNullObj (i.e. no attribute).

Examples:
geometrySurfaceConstraint/geometrySurfaceConstraint.h.
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.

[from before Maya 2016]

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.

[from before Maya 2016]

Deprecated:
Use MPxConstraintCommand::connectTarget(MDagPath &targetPath, int index) instead.
Parameters
[in]opaqueTarget
[in]index
Examples:
geometrySurfaceConstraint/geometrySurfaceConstraint.h.
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:
  • MS::kSuccess The method was successful
  • MS::kFailure An error occurred
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]modifierDG modifier used to undo and redo the command
Returns
Status code
Status Codes:
  • MS::kSuccess The method was successful
  • MS::kFailure An error occurred
Examples:
geometrySurfaceConstraint/geometrySurfaceConstraint.h.
MStatus setRestPosition ( MDGModifier modifier)
protectedvirtual

Override this method if you want to control the value to which the constraint node's rest position attribute (i.e.

the one returned by constraintRestAttribute()) and its corresponding enable attribute (i.e. the one returned by constraintEnableRestAttribute()) are initialized or if constraintRestAttribute() or constraintOutputAttribute() return attributes which are not of type MFnNumericData::k3Double.

The default behaviour is to initialize the rest position to the computed value of the output attribute (i.e. the one returned by constraintOutputAttribute()) and to initialize the enable attribute to true.

This method is called as part of the default doIt() handling, after the constrained object and all the targets have been connected and weights have been set. If you have overridden doIt() and it does not return MS::kUnknownParameter then this method will not be called.

Parameters
[in]modifierDG modifier used to undo and redo the command. During the initial execution of the command (i.e. doIt()) the modifier may contain changes which have not yet been committed. If your own changes cannot be added to the modifier then you may wish to call the modifier's doIt() to ensure that the state of the DG is as you expect.
Returns
Status code
Status Codes:
  • MS::kSuccess The method was successful
  • MS::kFailure An error occurred
  • MS::kUnknownParameter Tells Maya do its default behaviour.
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:
  • MS::kSuccess The method was successful
  • MS::kFailure An error occurred during the method
MStatus connectTargetAttribute ( void *  opaqueTarget,
int  index,
MObject constraintAttribute 
)
protected

This method is obsolete.

This method is not available in Python.

[from before Maya 2016]

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:
  • MS::kSuccess The method was successful
  • MS::kFailure An error occurred during the method
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:
  • MS::kSuccess The method was successful
  • MS::kFailure An error occurred during the method
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: