No products in the cart.

Research | Development

No products in the cart.

Speed Attribute (Maya)



Adds a speed attribute to any object(s) you select. In the fcurve editor just turn on Show Results from the view menu to see the new curve. The graph editor display will show a curve for the object’s speed, great to visualize or finetune how an object is accelerating/decelerating. Also lets you quickly see if an object is moving at a consistent or irregular speed.


Select your objects, and run the following code from a shelf button or hotkey.


#add speed attribute v1.2 now in KPH
#written by Eric Bates (c)2011
#based on mel script from Mark Kennedy
#Maya 2011
#Python script

#version history
#2011-04-28 v1.0 first version
#2011-04-28 v1.1 works properly now
#2012-02-07 v1.2 outputs speed in KPH(assuming scene is in meters)

import maya.cmds as cmds

selected = selection=True )
for s in selected:
    print s
    cmds.addAttr(s,longName='speed',attributeType = 'float', k=0)
    cmds.setAttr(s+".speed", cb=1)
    cmds.expression(o=s, s="float $lastPosX = `getAttr -t (frame-1) "+s+".tx`;\nfloat $lastPosY = `getAttr -t (frame-1) "+s+".ty`;\nfloat $lastPosZ = `getAttr -t (frame-1) "+s+".tz`;\nfloat $speed = abs(mag (<<"+s+".translateX-$lastPosX,"+s+".translateY-$lastPosY,"+s+".translateZ-$lastPosZ>>) );\nfloat $inKPH = $speed*24*60*60/1000;\n"+s+".speed = $inKPH;" ) September 4, 2012

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.