class MPxConstraintCommand

Jump to documentation

: public MPxCommand Proxy constraint command (OpenMayaAnim) (OpenMayaMPx.py)

Inheritance:

MPxConstraintCommand < MPxCommand

public members:

enum TargetType
kTransform
transform target
kGeometryShape
geometry shape(or children of) targets
kLast
MPxConstraintCommand ()
virtual ~MPxConstraintCommand ()
virtual MStatus doIt (const MArgList &argList)
virtual MStatus undoIt ()
virtual MStatus redoIt ()
virtual MStatus appendSyntax ()

protected members:

virtual MStatus parseArgs (const MArgList &argList)
MSyntax syntax ( MStatus *ReturnStatus = NULL) const
USE _syntax() IN SCRIPT
virtual MStatus doEdit ()
virtual MStatus doCreate ()
virtual MStatus doQuery ()
virtual void createdConstraint ( MPxConstraint *constraint)
virtual bool supportsOffset () const
virtual bool hasVectorFlags () const
virtual MTypeId constraintTypeId () const
virtual MPxConstraintCommand::TargetType targetType () const
virtual const MObject & aimVectorAttribute () const
virtual const MObject & upVectorAttribute () const
virtual const MObject & worldUpMatrixAttribute () const
virtual const MObject & worldUpTypeAttribute () const
virtual const MObject & worldUpVectorAttribute () const
virtual const MObject & offsetAttribute () const
virtual const MObject & constraintInstancedAttribute () const
virtual const MObject & constraintOutputAttribute () const
virtual const MObject & constraintRestAttribute () const
virtual const MObject & constraintEnableRestAttribute () const
virtual const MObject & constraintTargetInstancedAttribute () const
virtual const MObject & constraintTargetAttribute () const
virtual const MObject & constraintTargetWeightAttribute () const
virtual const MObject & objectAttribute () const
virtual void getObjectAttributesArray ( MObjectArray & array)
virtual void handleNewTargets ( MObject & dagObject )
virtual MStatus connectTarget (void *opaqueTarget, int index)
virtual MStatus connectObjectAndConstraint ( MDGModifier & modifier )
MStatus connectTargetAttribute ( void *opaqueTarget, int index, MObject & constraintAttr )
MStatus connectObjectAttribute ( const MObject & objectAttr, const MObject & constraintAttr, bool toConstraint = true, bool instanced = false)
const MObject transformObject ()

Inherited from MPxCommand:

public members:

virtual MStatus doIt ( const MArgList & args )
virtual MStatus undoIt ( )
virtual MStatus redoIt ( )
virtual bool isUndoable () const
virtual bool hasSyntax () const
MSyntax syntax () const
bool isHistoryOn () const
MString commandString () const
MStatus setHistoryOn ( bool state )
MStatus setCommandString ( const MString & )
static void displayInfo ( const MString & theInfo )
static void displayWarning ( const MString & theWarning )
static void displayError ( const MString & theError )
static void displayWarning ( const MString & theWarning, bool wantDisplayLineNumber )
static void displayError ( const MString & theError, bool wantDisplayLineNumber )
enum MResultType
kLong
kDouble
kString
kNoArg
static void clearResult ()
static void setResult ( int val )
static void setResult ( double val )
static void setResult ( bool val )
static void setResult ( const char* val )
static void setResult ( const MString & val )
static void setResult ( const MIntArray & val )
static void setResult ( const MDoubleArray & val )
static void setResult ( const MStringArray & val )
static void appendToResult ( int val )
static void appendToResult ( double val )
static void appendToResult ( bool val )
static void appendToResult ( const char* val )
static void appendToResult ( const MString & val )
static void appendToResult ( const MStringArray & val )
static MResultType currentResultType ()
static MStatus getCurrentResult ( int& val )
static MStatus getCurrentResult ( double& val )
static MStatus getCurrentResult ( MString & val )
static MStatus getCurrentResult ( MIntArray & val )
static MStatus getCurrentResult ( MDoubleArray & val )
static MStatus getCurrentResult ( MStringArray & val )
static int currentIntResult ( MStatus * ReturnStatus = NULL )
static double currentDoubleResult ( MStatus * ReturnStatus = NULL )
static MString currentStringResult ( MStatus * ReturnStatus = NULL )
MStatus setUndoable ( bool state )

Documentation

Proxy constraint command (OpenMayaAnim) (OpenMayaMPx.py)
Description

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.

Functions

MPxConstraintCommand:: MPxConstraintCommand ()
Constructor

MPxConstraintCommand:: ~MPxConstraintCommand ()

Description

Destructor. Local class data should be freed here.

MStatus MPxConstraintCommand:: doIt ( const MArgList & args )

Description

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.

Arguments

  • argList the command's argument list.

Return Value

  • Status code

Status Codes

  • MS::kSuccess The command was successful
  • MS::kFailure An error occurred during the command

MStatus MPxConstraintCommand:: undoIt ( )

Description

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.

Return Value

  • Status code

Status Codes

  • MS::kSuccess The undo was successful
  • MS::kFailure This method is not undoable

MStatus MPxConstraintCommand:: redoIt ( )

Description

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.

Return Value

  • Status code

Status Codes

  • MS::kSuccess The redo was successful
  • MS::kFailure An error occurred during the redo

MStatus MPxConstraintCommand:: parseArgs (const MArgList &argList)

Description

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.

Arguments

  • argList the command's argument list.

Return Value

  • Status code

Status Codes

  • MS::kSuccess The parseArgs was successful
  • MS::kFailure An error occurred during the parseArgs

MStatus MPxConstraintCommand:: doEdit ( )

Description

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.

Return Value

  • Status code

Status Codes

  • MS::kSuccess The edit was successful
  • MS::kFailure An error occurred during the edit

MStatus MPxConstraintCommand:: doCreate ( )

Description

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.

Return Value

  • Status code

Status Codes

  • MS::kSuccess The create was successful
  • MS::kFailure An error occurred during the create

MStatus MPxConstraintCommand:: doQuery ( )

Description

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.

Return Value

  • Status code

Status Codes

  • MS::kSuccess The query was successful
  • MS::kFailure An error occurred during the query

MStatus MPxConstraintCommand:: appendSyntax ()

Description

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

Return Value

  • MS::kSuccess operation successful
  • MS::kFailure operation failed

MSyntax MPxConstraintCommand:: syntax ( MStatus *ReturnStatus) const

Description

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.

Arguments

  • ReturnStatus return status

Return Value

  • the syntax object

Status Codes

  • MS::kSuccess operation successful
  • MS::kFailure operation failed

void MPxConstraintCommand:: createdConstraint ( MPxConstraint *constraint)

Description

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.

Arguments

  • constraint the constraint node created by the command.

bool MPxConstraintCommand:: supportsOffset () const

Description

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 MPxConstraintCommand:: hasVectorFlags () const

Description

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

void MPxConstraintCommand:: handleNewTargets ( MObject & dagObject )

Description

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.

Arguments

  • dagObject the new constraint target

MTypeId MPxConstraintCommand:: constraintTypeId () const

Description

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.

MPxConstraintCommand::TargetType MPxConstraintCommand:: targetType () const

Description

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.

const MObject & MPxConstraintCommand:: aimVectorAttribute () const

Description

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 & MPxConstraintCommand:: upVectorAttribute () const

Description

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 & MPxConstraintCommand:: worldUpMatrixAttribute () const

Description

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 & MPxConstraintCommand:: worldUpTypeAttribute () const

Description

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 & MPxConstraintCommand:: worldUpVectorAttribute () const

Description

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 & MPxConstraintCommand:: offsetAttribute () const

Description

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 & MPxConstraintCommand:: constraintInstancedAttribute () const

Description

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.

const MObject & MPxConstraintCommand:: constraintOutputAttribute () const

Description

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.

const MObject & MPxConstraintCommand:: constraintRestAttribute () const

Description

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 & MPxConstraintCommand:: constraintEnableRestAttribute () const

Description

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 & MPxConstraintCommand:: constraintTargetInstancedAttribute () const

Description

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.

const MObject & MPxConstraintCommand:: constraintTargetAttribute () const

Description

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.

const MObject & MPxConstraintCommand:: constraintTargetWeightAttribute () const

Description

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.

const MObject & MPxConstraintCommand:: objectAttribute () const

Description

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.

void MPxConstraintCommand:: getObjectAttributesArray ( MObjectArray & array)

Description

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

MStatus MPxConstraintCommand:: connectTarget (void *opaqueTarget, int index)

Description

This method is used for connecting the constraint and the target at the target's array index. The utility method MPxConstraintCommand::connectTargetAttribute() is used to connect the attributes.

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

Arguments

  • opaqueTarget opaque parameter that is passed to connectTargetAttribute()
  • index the array index that is passed to connectTargetAttribute()

Return Value

  • Status code

Status Codes

  • MS::kSuccess The method was successful
  • MS::kFailure An error occurred

MStatus MPxConstraintCommand:: connectObjectAndConstraint ( MDGModifier & )

Description

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.

Arguments

  • modifier used for setting plug values such as translation

Return Value

  • Status code

Status Codes

  • MS::kSuccess The method was successful
  • MS::kFailure An error occurred

MStatus MPxConstraintCommand:: connectTargetAttribute ( void *opaqueTarget, int index, MObject & constraintAttribute )

Description

This method is used by connectTarget() to make any required connections for the constraint.

Arguments

  • opaqueTarget as passed to connectTarget()
  • index as passed to connectTarget()
  • constraintGeometryAttribute as defined by the constraint

Return Value

  • Status code

Status Codes

  • MS::kSuccess The method was successful
  • MS::kFailure An error occurred during the method

MStatus MPxConstraintCommand:: connectObjectAttribute ( const MObject & objectAttr, const MObject & constraintAttr, bool toConstraint, bool instanced )

Description

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

Arguments

  • opaqueTarget as passed to connectTarget()
  • index as passed to connectTarget()
  • constraintAttr as defined by the constraint

Return Value

  • Status code

Status Codes

  • MS::kSuccess The method was successful
  • MS::kFailure An error occurred during the method

const MObject MPxConstraintCommand:: transformObject ()

Description

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.

This class has no child classes.


Autodesk® Maya® 2008 © 1997-2007 Autodesk, Inc. All rights reserved. doc++ Copyright