Checking Keyframe curve type

  • I'm creating a python script to export keyframe data. When doing this I want to check to make sure that the keyframes are on either a position or a rotation track and ignore all others. I'm a little lost on how to do that check. I'm currently building this in xpresso with a python node and hoping to later convert it to a plug in. Here is my current code with comments.

    import c4d
    import math
    def main():
        # Get a list of all the animation tracks for the object
        track = Object.GetCTracks()
        #iterate through the list of tracks
        for x in track:
            #---Here I would like to check if this is rotation/position track or something that should be ignored ----
            print x
            #---- When x is printed I receive <c4d.CTrack object called 'Position . Y/Track' with ID 5350 at 0x0000025FC3AE2770> so I can see its position but I don't know how to sort that out -----

    I think what I'm looking for is a GetTrackName or something along those lines?

    Edit a_block: Added code tags

  • Global Moderator

    Hello and welcome,

    what exactly do you mean with "export keyframe data"? Do you want to write data into a file? The best way to develop such code would be in a Python script that you can edit and execute in the Script Manager. A XPresso Python node is meant to contain code that is executed as part of XPresso to define the behavior of the XPresso network. A XPresso Python node should not be used to modify the scene or to perform I/O operations.

    A CTrack object stores the DescID of the associated parameter. You can access that DescID with GetDescriptionID().

    Alternatively you can use BaseList2D.FindCTrack() to search for the CTrack associated with a certain parameter DescID. You find an example on GitHub.

    You find general information on how to use CTrack and DescID also in the C++ documentation:

    best wishes,