# Swap two curves in the Graph Editor

There is another question on this forum with the same title but the answer given and accepted has nothing to do with what I am asking here. What I ask is this:

Suppose I have a cube rotating by X and Y. Now I need to transfer all keyframes in X to Y and vice-versa or, in other words, swap X and Y rotation animations.

Is that possible from the graph editor or by any other mean?

Quite simply swap the array_index property, which designates which component of an array property (eg location.x or location[0], has array_index == 0), of the two fcurves.

Example below using the python console, location as an example, change to rotation_euler for Euler rotation.

>>> action = D.actions['CubeAction']
>>> fx = action.fcurves.find('location', index=0) # location.x
>>> fy = action.fcurves.find('location', index=1) # location.y
>>> fx.array_index, fy.array_index = fy.array_index, fx.array_index


It is. Now, there may be another, more efficient way of doing this (add-on, maybe? or a bit of Python would probably be the quickest way), but here's one approach I've found just using the graph editor:

Basically, the method below is just like swapping two variables (say X and Y) in programming where you'll need to have a third variable (say Z) for an intermediate step. To recap, the steps are:

1. Assign Z = Y
2. Assign Y = X
3. Assign X = Z

To do the same thing in Blender in the graph editor, you'll need a channel where you can temporarily store the keyframes from the Y-channel. For this you might be able to make use of the Z-channel in the same object if that's not being used (e.g. its keyframes all have a value of 0), but if not you can always create a dummy object with at least one keyframe and pick whatever channel in that object to act as the "Z-channel" mentioned below. (The same process can be used with a dummy object, you'll just need to switch between the objects to make a channel visible.)

I'm assuming some things here, like you're familiar with how to select all visible keyframes, but let me know if any clarification is needed.

1. Make sure your current frame is frame 1 and select the object you need to switch channels
2. In the graph editor, isolate the Y-channel (turn off visibility of the other channels) and select all of the Y-channel keyframes
3. Press Ctrl-c (Cmd-c on Mac, right?) to copy the Y-channel keyframes to clipboard
4. Turn on the Z-channel and make sure it's the active channel
5. Press Ctrl-v (Cmd-v on Mac?) to paste the keyframes copied in step 3. Your Z-channel should now look exactly like the X-channel
6. Isolate the X-channel (turn off visibility of the other channels) and select all of the X-channel keyframes
7. Press Ctrl-c to copy the keyframes
8. Turn on the Y-channel and make sure it's the active channel
9. Press Ctrl-v to paste the keyframes copied in step 7. Your Y-channel should now look exactly like the X-channel
10. Isolate the Z-channel (turn off visibility of the other channels) and select all of the Z-channel keyframes
11. Press Ctrl-c to copy the keyframes
12. Turn on the X channel and make sure it's the active channel
13. Press Ctrl-v to paste the keyframes copied in step 11.
14. Reset the Z-channel keyframes back to whatever they need to be.