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

Synopsis

normalConstraint( [target...] object , [aimVector=[float, float, float]], [layer=string], [name=string], [remove=boolean], [targetList=boolean], [upVector=[float, float, float]], [weight=float], [weightAliasList=boolean], [worldUpObject=name], [worldUpType=string], [worldUpVector=[float, float, float]])

Note: Strings representing object names and arguments must be separated by commas. This is not depicted in the synopsis.

normalConstraint is undoable, queryable, and editable.

Constrain an object's orientation based on the normal of the target surface(s) at the closest point(s) to the object. A normalConstraint takes as input one or more surface shapes (the targets) and a DAG transform node (the object). The normalConstraint orients the constrained object such that the aimVector (in the object's local coordinate system) aligns in world space to combined normal vector. The upVector (again the the object's local coordinate system) is aligned in world space with the worldUpVector. The combined normal vector is a weighted average of the normal vector for each target surface at the point closest to the constrained object.

Return value

string[]Name of the created constraint node

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

Related

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

Flags

aimVector, layer, name, remove, targetList, upVector, weight, weightAliasList, worldUpObject, worldUpType, worldUpVector
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) boolean edit
removes the listed target(s) from the constraint.
targetList(tl) boolean query
Return the list of target objects.
weightAliasList(wal) boolean 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.
aimVector(aim) [float, float, float] createqueryedit
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.
upVector(u) [float, float, float] createqueryedit
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.
worldUpVector(wu) [float, float, float] createqueryedit
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.
worldUpObject(wuo) name createqueryedit
Set the DAG object use for worldUpType "object" and "objectrotation". See worldUpType for greater detail. The default value is no up object, which is interpreted as world space.
worldUpType(wut) string createqueryedit
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 "objectrotation" then 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 "none" no twist calculation is performed by the constraint, with the resulting "upVector" orientation based previous orientation of the constrained object, and the "great circle" rotation needed to align the aim vector with its constraint. The default worldUpType is "vector".

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.

Python examples

import maya.cmds as cmds

cmds.normalConstraint( 'surf1', 'cube1' )
# orients the aim vector of cube1 in it's local coordinate space,
# to the normal vector of surf1 at the closest point to  cube1.
cmds.normalConstraint( 'surf1', 'surf2', 'cube2', w=.1 )
# uses the average of the normals from surf1 and surf2.
cmds.normalConstraint( 'surf1', 'cube2', e=True, w=10. )
# sets the weight for surf1's effect on cube2 to 10.
cmds.normalConstraint( 'surf2', 'cube2', e=True, rm=True )
# removes surf2 from cube2's normalConstraint.
cmds.normalConstraint( 'surf3', 'cube2' )
# adds surf3 to cube2's normalConstraint with the default weight.