How to get the camera's trajectory in time in python?

104 views
Skip to first unread message

dag.x...@gmail.com

unread,
Apr 21, 2017, 4:47:13 PM4/21/17
to Python Programming for Autodesk Maya
Hi all. I need to get trajectory of camera that is displayed in the Graph Editor. The trajectory is created using "curve" and "attack to motion path".
I found this script but it only works for animations and shows dependence on the frame but not on time. For camera is unfortunately not working.
Ultimately I need to speed cameras, tell me how can this best be done?

/*************CODE************************/
import maya.cmds as cmds

def getAnimationData():
objs = cmds.ls(selection=True)
obj = objs[0]
print obj

animAttributes = cmds.listAnimatable(obj);

for attribute in animAttributes:

numKeyframes = cmds.keyframe(attribute, query=True,
keyframeCount=True)

if (numKeyframes > 0):
print("---------------------------")
print("Found ", numKeyframes, " keyframes on ",
attribute)

times = cmds.keyframe(attribute, query=True,
index=(0,numKeyframes), timeChange=True)
values = cmds.keyframe(attribute, query=True,
index=(0,numKeyframes), valueChange=True)

print('frame#, time, value')
for i in range(0, numKeyframes):
print(i, times[i], values[i])

print("---------------------------")

getAnimationData()

Kyle Burris

unread,
Apr 28, 2017, 12:41:47 PM4/28/17
to Python Programming for Autodesk Maya
I'm a little confused by your question. Do you just want to know how fast a camera is moving? What would be your unit of measurement, units per frame? If that's the case you can do it in a few lines with MVector. Please clarify your question and I can try to help.

Kyle
Reply all
Reply to author
Forward
0 new messages