Go to: Synopsis. Return value. Related. Flags. Python examples.
geometryConstraint(
[target...] object
, [name=string], [remove=boolean], [targetList=boolean], [weight=float], [weightAliasList=boolean])
Note: Strings representing object names and arguments must be separated by commas. This is not depicted in the synopsis.
geometryConstraint is undoable, queryable, and editable.
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.
string[] | Name of the created constraint node |
In query mode, return type is based on queried flag.
aimConstraint, normalConstraint, orientConstraint, parent, pointConstraint, poleVectorConstraint, scaleConstraint, tangentConstraint
name, remove, targetList, weight, weightAliasList
Long name (short name) |
Argument types |
Properties |
name(n)
|
string
|
|
|
Sets the name of the constraint node to the specified
name. Default name is constrainedObjectName_constraintType
|
|
weight(w)
|
float
|
|
|
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)
|
boolean
|
|
|
removes the listed target(s) from the constraint.
|
|
targetList(tl)
|
boolean
|
|
|
Return the list of target objects.
|
|
weightAliasList(wal)
|
boolean
|
|
|
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
|
|
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 have multiple arguments, passed either as a tuple or a list.
|
import maya.cmds as cmds
# Constrain cube1 to surf1 at the closest point to cube1.
cmds.geometryConstraint( 'surf1', 'cube1' )
# Will prefer surf1 though the weights are equal
cmds.geometryConstraint( 'surf1', 'surf2', 'cube2', w=.1 )
# Now constraints cube2 to lie on surf2 as it's weight is greater
cmds.geometryConstraint( 'surf2', 'cube2', e=True, w=10. )
# Removes surf2 from cube2's geometryConstraint.
cmds.geometryConstraint( 'surf2', 'cube2', e=True, rm=True )
# Adds surf3 to cube2's geometryConstraint with the default weight.
cmds.geometryConstraint( 'surf3', 'cube2' )