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


#1

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?


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()