You can ignore the functions, they are just used to create the example, the code lines below the functions build the example:
import bpy
def setDriver(bone, fn="0", axis=0, movementType='rotation_euler'):
eulerDriver = bone.driver_add(movementType)
eulerDriver[axis].driver.type = 'SCRIPTED'
eulerDriver[axis].driver.expression = fn
return eulerDriver
def getEuler(str_bone_name):
bone = bpy.context.object.pose.bones[str_bone_name]
bone.rotation_mode = 'XYZ'
return bone
bpy.ops.object.armature_add(enter_editmode=False, location=(0, 0, 0))
bpy.ops.transform.rotate(value=0.785398, orient_axis='Y', orient_type='NORMAL')
setDriver(getEuler("Bone"), "frame*.02", 1, 'location')
Change to OBJECT mode and click the play button.
The problem: Having rotated the bone 45 degrees, I need the driver to drive it along the orthogonal x- axis, not in a 45 degree direction as it currently does . . . . if I remember correctly, there is a way to display the axis and then rotate it so that, without changing the mode or the bone orientation, then it will travel along the x-axis when you hit the play button. The reason why I want to change the axis rather than do other things is this is a change on something that already has a huge amount of code following it, and I do not want to effect those actions that follow it.