I want to export all of the animation information from Blender to use in my application. I have written a Blender add-on in Python that mostly works, I am just missing one vital piece of data that I can't find in the API guide, and that is the quantity that is modified by each channel.

The channel has a data_path property that contains location but how can I tell if this is the x, y or z location, an axis rotation or something else.

Here is a snippet of my code that gathers up all of the animation data for exporting:

    def serializeAnimations(self):
        for action in bpy.data.actions:
            Logger.log('Serializing action ' + action.name)
            groups = []
            for group in action.groups:
                channels = []
                for channel in group.channels:
                    keyframes = []
                    for keyframe in channel.keyframe_points:
                            "type": keyframe.type,
                            "co": self.serializeCurve(keyframe.co),
                            "amplitude": keyframe.amplitude,
                            "back": keyframe.back,
                            "interpolation": keyframe.interpolation,
                            "handle_left": self.serializeCurve(keyframe.handle_left),
                            "handle_left_type": keyframe.handle_left_type,
                            "handle_right": self.serializeCurve(keyframe.handle_right),
                            "handle_right_type": keyframe.handle_right_type,
                        "datapath": channel.data_path,
                        "extrapolation": channel.extrapolation,
                        "color": self.serializeColor(channel.color),
                        "keyframes": keyframes})
                    "name": group.name,
                    "channels": channels})
                "name": action.name,
                "frames": self.serializeRange(action.frame_range),
                "groups": groups })

  • $\begingroup$ i think the rotation axis is determined by the array_index (0 -> x, 1 -> y, 2 -> z) $\endgroup$ – Chris Jun 1 at 5:19
  • $\begingroup$ Ahh, it looked like it was the index position within the collection. Makes sense. Thanks. $\endgroup$ – bikeman868 Jun 1 at 18:24
  • $\begingroup$ You are welcome $\endgroup$ – Chris Jun 1 at 18:45
  • $\begingroup$ That moved me forwards, but now I have found some other gaps. Where can I find the speed of the animation in frames per second, whether the animation loops or just plays once and stops, and for rotations that are not around the mesh origin where do I find the origin of rotation? $\endgroup$ – bikeman868 Jun 1 at 19:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.