Go to: Synopsis. Return value. Related. Flags. MEL examples.

Synopsis

parentConstraint [-createCache float float] [-deleteCache] [-layer string] [-maintainOffset] [-name string] [-remove] [-skipRotate string] [-skipTranslate string] [-targetList] [-weight float] [-weightAliasList] [target ...] [object]

parentConstraint is undoable, queryable, and editable.

Constrain an object's position and rotation so that it behaves as if it were a child of the target object(s). In the case of multiple targets, the overall position and rotation of the constrained object is the weighted average of each target's contribution to the position and rotation of the object. A parentConstraint takes as input one or more "target" DAG transform nodes at which to position and rotate the single "constraint object" DAG transform node. The parentConstraint positions and rotates the constrained object at the weighted average of the world space position, rotation and scale target objects.

Return value

string[]Name of the created constraint node

In query mode, return type is based on queried flag.

Related

aimConstraint, geometryConstraint, normalConstraint, orientConstraint, pointConstraint, poleVectorConstraint, scaleConstraint, tangentConstraint

Flags

createCache, deleteCache, layer, maintainOffset, name, remove, skipRotate, skipTranslate, targetList, weight, weightAliasList
Long name (short name) Argument types Properties
-name(-n) string createqueryedit
Sets the name of the constraint node to the specified name. Default name is constrainedObjectName_constraintType
-weight(-w) float createqueryedit
Sets the weight value for the specified target(s). If not given at creation time, the default value of 1.0 is used.
-remove(-rm) edit
removes the listed target(s) from the constraint.
-targetList(-tl) query
Return the list of target objects.
-weightAliasList(-wal) query
Returns the names of the attributes that control the weight of the target objects. Aliases are returned in the same order as the targets are returned by the targetList flag
-layer(-l) string createedit
Specify the name of the animation layer where the constraint should be added.
-skipTranslate(-st) string createmultiuse
Causes the axis specified not to be considered when constraining translation. Valid arguments are "x", "y", "z" and "none".
-skipRotate(-sr) string createmultiuse
Causes the axis specified not to be considered when constraining rotation. Valid arguments are "x", "y", "z" and "none".
-maintainOffset(-mo) create
If this flag is specified the position and rotation of the constrained object will be maintained.
-createCache(-cc) float float edit
This flag is used to generate an animation curve that serves as a cache for the constraint. The two arguments define the start and end frames.
The cache is useful if the constraint has multiple targets and the constraint's interpolation type is set to "no flip". The "no flip" mode prevents flipping during playback, but the result is dependent on the previous frame. Therefore in order to consistently get the same result on a specific frame, a cache must be generated. This flag creates the cache and sets the constraint's interpolation type to "cache". If a cache exists already, it will be deleted and replaced with a new cache.
-deleteCache(-dc) edit
Delete an existing interpolation cache.

Flag can appear in Create mode of command Flag can appear in Edit mode of command
Flag can appear in Query mode of command Flag can be used more than once in a command.

MEL examples

// Position cube1 at the location of cone1
// Rotate cube1 to the rotation of cone1
parentConstraint  cone1 cube1;
// Position cube1 at the average of the locations of cone1 and surf2
// Rotate cube1 to the average of the rotations of cone1 and surf2
parentConstraint -w .1 cone1 surf2 cube2;
// Sets the weight for cone1's effect on cube2 to 10.
parentConstraint -e -w 10. cone1 cube2;
// Removes surf2 from cube2's parentConstraint
parentConstraint -e -rm surf2 cube2;
// Adds surf3 to cube2's parentConstraint with the default weight
parentConstraint surf3 cube2;
// Constrain position only in the y-axis with rotation
// constraining in all axes
parentConstraint -st x -st z cone2 cube2;