pymel.core.animation.pathAnimation¶
- pathAnimation(*args, **kwargs)¶
The pathAnimation command constructs the necessary graph nodes and their interconnections for a motion path animation. Motion path animation requires a curve and one or more other objects. During the animation, the objects will be moved along the 3D curve or the curveOnSurface.There are two ways to specify the moving objects: by explicitly specifying their names in the command line, orby making the objects selected (interactively, or through a MEL command).Likewise, there are two ways to specify a motion curve: by explicitly specifying the name of the motion curve in the command line (i.e. using the -c curve_name option), orby selecting the moving objects first before selecting the motion curve. I.e. if the name of the motion curve is not provided in the command line, the curve will be taken to be the last selected object in the selection list.When the end time is not specified: only one keyframe will be created either at the current time, or at the specified start time.
Flags:
Long Name / Short Name Argument Types Properties bank / b bool If on, enable alignment of the up axis of the moving object(s) to the curvature of the path geometry.Default is false.When queried, this flag returns a boolean. bankScale / bs float This flag specifies a factor to scale the amount of bank angle.Default is 1.0When queried, this flag returns a float. bankThreshold / bt float This flag specifies the limit of the bank angle.Default is 90 degreesWhen queried, this flag returns an angle. curve / c unicode This flag specifies the name of the curve for the path.Default is NONEWhen queried, this flag returns a string. endTimeU / etu time This flag specifies the ending time of the animation for the u parameter.Default is NONE.When queried, this flag returns a time. endU / eu float This flag specifies the ending value of the u parameterization for the animation.Default is the end parameterization value of the curve.When queried, this flag returns a linear. follow / f bool If on, enable alignment of the front axis of the moving object(s).Default is false.When queried, this flag returns a boolean. followAxis / fa unicode This flag specifies which object local axis to be aligned to the tangent of the path curve.Default is yWhen queried, this flag returns a string. fractionMode / fm bool If on, evaluation on the path is based on the fraction of length of the path curve.Default is false.When queried, this flag returns a boolean. inverseFront / inverseFront bool This flag specifies whether or not to align the front axis of the moving object(s) to the opposite direction of the tangent vector of the path geometry.Default is false.When queried, this flag returns a boolean. inverseUp / iu bool This flag specifies whether or not to align the up axis of the moving object(s) to the opposite direction of the normal vector of the path geometry.Default is false.When queried, this flag returns a boolean. name / n unicode This flag specifies the name for the new motion path node. (instead of the default name)When queried, this flag returns a string. startTimeU / stu time This flag specifies the starting time of the animation for the u parameter.Default is the the current time.When queried, this flag returns a time. startU / su float This flag specifies the starting value of the u parameterization for the animation.Default is the start parameterization value of the curve.When queried, this flag returns a linear. upAxis / ua unicode This flag specifies which object local axis to be aligned a computed up direction.Default is zWhen queried, this flag returns a string. useNormal / un bool This flag is now obsolete. Use -wut/worldUpType instead. worldUpObject / wuo PyNode Set the DAG object to use for worldUpType objectand objectrotation. See -wut/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 normal. 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 worldUpObject is ignored. Finally, if the value is normalthe upVector is aligned to the path geometry. 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 for greater detail. If not given at creation time, the default value of (0.0, 1.0, 0.0) is used. Flag can have multiple arguments, passed either as a tuple or a list. Derived from mel command maya.cmds.pathAnimation
Example:
import pymel.core as pm # Create a set of simple objects for the motion path animation # create a path, e,g, a curve path = pm.curve(d=3,p=[(-10, 0, 0),(-6, 0, 10),(-3, 0, -10),(10, 0, 0)],k=[0, 0, 0, 1, 1, 1]) # create an object, e.g. a sphere object = pm.sphere() pm.scale( 0.5, 2.0, 0.2 ) # 1. To animate the sphere along the curve, with one keyframe at # the current time: pm.pathAnimation( object[0], c=path ) # Result: u'motionPath1' # # or: pm.select( object[0], path ) pm.pathAnimation() # 2. To animate the sphere along the curve, from time 0 to time 30: pm.pathAnimation( object[0], stu=0, etu=30, c=path ) # 3. To align the sphere to its path: pm.pathAnimation( object[0], stu=0, etu=30, follow=True, c=path ) # 4. To align the Z axis of sphere to the tangent of the curve, and # to align the Y axis of the sphere to the up direction of the # motion curve: pm.pathAnimation( object[0], stu=0, etu=30, fa='z', ua='y', c=path ) # 5. To align the Z axis of sphere to the tangent of the motion curve, # to align the Y axis of sphere to the up direction of the motion # curve, and to bank with the curvature of the motion curve: pm.pathAnimation( object[0], stu=0, etu=30, fa='z', ua='y', bank=True, c=path ) # 6. To change the setting on the bankScale for the motionPath1 # to negative 2.5 (i.e. bank out and multiply the computed # bank value by 2.5): pm.pathAnimation( 'motionPath1', edit=True, bankScale=-2.5 ) # Notes: # If the computed bank angles are not large enough, the user can # specify the bankScale to amplify them. The default value is 1. # Positive bankScale produces inward bank angle, # negative bankScale produces outward bank angle. # The user can also change the maximum bank angle through # the bankThreshold option. Default value is 90 degrees.