Constrain an object’s orientation to point at a target object or at the average position of a number of targets. An aimConstraint takes as input one or more targetDAG transform nodes at which to aim the single constraint objectDAG transform node. The aimConstraint orients the constrained object such that the aimVector (in the object’s local coordinate system) points to the in weighted average of the world space position target objects. The upVector (again the the object’s local coordinate system) is aligned in world space with the worldUpVector.
added new syntax for querying the weight of a target object, by passing the constraint first:
aimConstraint( 'pCube1_aimConstraint1', q=1, weight ='pSphere1' )
aimConstraint( 'pCube1_aimConstraint1', q=1, weight =['pSphere1', 'pCylinder1'] )
aimConstraint( 'pCube1_aimConstraint1', q=1, weight =[] )
Long name (short name) | Argument Types | Properties | |
---|---|---|---|
aimVector (aim) | float, float, float | ||
Set the aim vector. This is the vector in local coordinates that points at the target. If not given at creation time, the default value of (1.0, 0.0, 0.0) is used. |
|||
layer (l) | unicode | ||
|
|||
maintainOffset (mo) | bool | ||
|
|||
name (n) | unicode | ||
|
|||
offset (o) | float, float, float | ||
|
|||
remove (rm) | bool | ||
|
|||
skip (sk) | unicode | ||
Specify the axis to be skipped. Valid values are x, y, zand none. During creation, noneis the default. Flag can have multiple arguments, passed either as a tuple or a list. |
|||
targetList (tl) | bool | ||
|
|||
upVector (u) | float, float, float | ||
Set local up vector. This is the vector in local coordinates that aligns with the world up vector. If not given at creation time, the default value of (0.0, 1.0, 0.0) is used. |
|||
weight (w) | float | ||
|
|||
weightAliasList (wal) | bool | ||
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 |
|||
worldUpObject (wuo) | PyNode | ||
Set the DAG object use for worldUpType objectand objectrotation. See worldUpType for greater detail. The default value is no up object, which is interpreted as world space. |
|||
worldUpType (wut) | unicode | ||
Set the type of the world up vector computation. The worldUpType can have one of 5 values: scene, object, objectrotation, vector, or none. If the value is scene, the upVector is aligned with the up axis of the scene and worldUpVector and worldUpObject are ignored. If the value is object, the upVector is aimed as closely as possible to the origin of the space of the worldUpObject and the worldUpVector is ignored. If the value is objectrotationthen the worldUpVector is interpreted as being in the coordinate space of the worldUpObject, transformed into world space and the upVector is aligned as closely as possible to the result. If the value is vector, the upVector is aligned with worldUpVector as closely as possible and worldUpMatrix is ignored. Finally, if the value is noneno twist calculation is performed by the constraint, with the resulting upVectororientation based previous orientation of the constrained object, and the great circlerotation needed to align the aim vector with its constraint. The default worldUpType is vector. |
|||
worldUpVector (wu) | float, float, float | ||
Set world up vector. This is the vector in world coordinates that up vector should align with. See -wut/worldUpType (below)for greater detail. If not given at creation time, the default value of (0.0, 1.0, 0.0) is used. |
Derived from mel command maya.cmds.aimConstraint
Example:
import pymel.core as pm
# Orients the aim vector of cube1 in it's local coordinate space, to point at cone1.
pm.aimConstraint( 'cone1', 'cube1' )
# Aims cube2 at the average of the position of cone1 and surf2
pm.aimConstraint( 'cone1', 'surf2', 'cube2', w=.1 )
# Sets the weight for cone1's effect on cube2 to 10.
pm.aimConstraint( 'cone1', 'cube2', e=True, w=10.0 )
# Removes surf2 from cube2's aimConstraint.
pm.aimConstraint( 'surf2', 'cube2', e=True, rm=True )
# Adds surf3 to cube2's aimConstraint with the default weight.
pm.aimConstraint( 'surf3', 'cube2' )
# Aim constrain the z-axis only of sph2 to sph1
pm.aimConstraint( 'sph1', 'sph2', skip=["x","y"] )