Constrain an object’s position based on the shape of the target surface(s) at the closest point(s) to the object. A geometryConstraint takes as input one or more surface shapes (the targets) and a DAG transform node (the object). The geometryConstraint position constrained object such object lies on the surface of the target with the greatest weight value. If two targets have the same weight value then the one with the lowest index is chosen.
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 | |
---|---|---|---|
layer (l) | unicode | ||
Specify the name of the animation layer where the constraint should be added.Flag can appear in Create mode of commandFlag can have multiple arguments, passed either as a tuple or a list. |
|||
name (n) | unicode | ||
|
|||
remove (rm) | bool | ||
|
|||
targetList (tl) | bool | ||
|
|||
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 |
Derived from mel command maya.cmds.geometryConstraint
Example:
import pymel.core as pm
# Constrain cube1 to surf1 at the closest point to cube1.
pm.geometryConstraint( 'surf1', 'cube1' )
# Will prefer surf1 though the weights are equal
pm.geometryConstraint( 'surf1', 'surf2', 'cube2', w=.1 )
# Now constraints cube2 to lie on surf2 as it's weight is greater
pm.geometryConstraint( 'surf2', 'cube2', e=True, w=10. )
# Removes surf2 from cube2's geometryConstraint.
pm.geometryConstraint( 'surf2', 'cube2', e=True, rm=True )
# Adds surf3 to cube2's geometryConstraint with the default weight.
pm.geometryConstraint( 'surf3', 'cube2' )