C++ API Reference
|
Proxy constraint command. More...
#include <MPxConstraintCommand.h>
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... | |
MPxConstraint * | constraintNode () |
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 MObject & | aimVectorAttribute () const |
This method returns an attribute which defines the aim vector of a constraint. More... | |
virtual const MObject & | upVectorAttribute () const |
This method returns an upVector attribute that is used in conjunction with the aimVector. More... | |
virtual const MObject & | worldUpMatrixAttribute () const |
This method returns an worldUpMatrix attribute that is used in conjunction with the aimVector. More... | |
virtual const MObject & | worldUpTypeAttribute () const |
This method returns an worldUpType attribute that is used in conjunction with the aimVector. More... | |
virtual const MObject & | worldUpVectorAttribute () const |
This method returns an worldUpVector attribute that is used in conjunction with the aimVector. More... | |
virtual const MObject & | offsetAttribute () const |
This method returns the offset attribute and must be implemented if supportsOffset() returns true. More... | |
virtual const MObject & | constraintInstancedAttribute () const |
This method returns the attribute on the constraint node that connects to an instanced constraint attribute of the constrained object. More... | |
virtual const MObject & | constraintOutputAttribute () const |
This method returns the attribute this constraint will connect to the constrained attribute of the constrained object. More... | |
virtual const MObject & | constraintRestAttribute () const |
This method returns the attribute used to store the constraint's rest state. More... | |
virtual const MObject & | constraintEnableRestAttribute () const |
This method returns the attribute used to enable and disable the rest state at runtime. More... | |
virtual const MObject & | constraintTargetInstancedAttribute () const |
This method returns the constraintTargetInstanced attribute for the constraint. More... | |
virtual const MObject & | constraintTargetAttribute () const |
This method returns the constraintTarget attribute for the constraint. More... | |
virtual const MObject & | constraintTargetWeightAttribute () const |
This method returns the constraintTargetWeight attribute for the constraint. More... | |
virtual const MObject & | objectAttribute () 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... | |
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.
enum TargetType |
|
override |
Destructor.
Local class data should be freed here.
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.
[in] | args | the command's argument list. |
Reimplemented from MPxCommand.
|
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.
Reimplemented from MPxCommand.
|
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.
Reimplemented from MPxCommand.
|
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".
|
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.
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:
[in] | argList | the command's argument list. |
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.
[out] | ReturnStatus | return status |
|
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:
|
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:
|
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:
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.
|
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.
[in] | constraint | the constraint node created by the command. |
|
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.
|
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().
|
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.
|
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.
|
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).
|
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).
|
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).
|
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).
|
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).
|
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).
|
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).
|
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).
|
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).
|
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).
|
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).
|
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).
|
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).
|
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).
|
protectedvirtual |
This method returns the list of attributes this particular constraint considers when inserting a pair blend.
[in] | array | Array of attributes. |
|
protectedvirtual |
This method is obsolete.
This method is not available in Python.
[from before Maya 2016]
[in] | dagObject |
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.
[in] | dagObject | path to the new constraint target |
|
protectedvirtual |
This method is obsolete.
This method is not available in Python.
[from before Maya 2016]
[in] | opaqueTarget | |
[in] | index |
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.
[in] | targetPath | DAG path of the target |
[in] | index | index for this target in the node's constraint target attribute |
|
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.
[in] | modifier | DG modifier used to undo and redo the command |
|
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.
[in] | modifier | DG 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. |
|
protected |
Utility method to make any required connections for the constraint.
Note that it is called by the default implementation of connectTarget().
[in] | opaqueTarget | as passed to connectTarget() |
[in] | index | as passed to connectTarget() |
[in] | constraintAttribute | as defined by the constraint |
|
protected |
This method is obsolete.
This method is not available in Python.
[from before Maya 2016]
[in] | opaqueTarget | |
[in] | index | |
[in] | constraintAttribute |
|
protected |
Utility method to make any required connections for the constraint.
[in] | targetPath | as passed to connectTarget() |
[in] | index | as passed to connectTarget() |
[in] | targetAttribute | as defined by the target |
[in] | constraintAttr | as defined by the constraint |
[in] | instanced | true if targetAttribute is an instanced attribute |
|
protected |
This method can be used by connectObjectAndConstraint() to make any required connections between the constraint and the constrained object.
[in] | objectAttr | as passed to connectTarget() |
[in] | constraintAttr | as defined by the constraint |
[in] | toConstraint | true if connection is from object to constraint, false if connection is from constraint to object |
[in] | instanced | true if objectAttr must be indexed by instance number |
|
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.