Updating bone display problem & bone isSelected function

I’m trying to set some bone values with Python but although the data seems to change, the window doesn’t redraw the information.

Specifically, I’m trying to write a script to reset the bone roll values to zero.

#!BPY

"""
Name: 'Zero Roll Angles'
Blender: 233
Group: 'Animation'
Tip: 'Set the roll angles of bones to zero'
"""

import Blender
from Blender import *

selected = Blender.Object.GetSelected()
if selected[0].getType() == "Armature":
	skeleton = selected[0].getData()
 	print skeleton.getBones()

bones = skeleton.getBones()

for bone in bones:
   print bone
   #if bone.isSelected()
   print bone.getRoll()
   bone.setRoll(0.0)
   print bone.getRoll()
   
   Blender.Redraw()
   Blender.Window.RedrawAll()

If you make a test armature and set some roll values and dump the above file into your python folder, it will load in the animation menu. In the console output, it will show you the roll value before and after. These values change but the display remains the same. This happens under 2.37a too.

I tried the example script in the 2.37 PYAPI and it does a similar thing. The code at the top of this page:

http://www.blender.org/documentation/237PythonDoc/Bone-module.html

It adds data to the scene and the outliner shows an update but the bones don’t appear in the 3D window.

The other thing I was wondering about was a method to check if a bone is selected. There is such a method for object but it doesn’t seem to work for bones because they don’t seem to be classed as objects, which I can understand because they don’t show in object mode but those attributes are very useful.

Ideally, all I want to do is write a script like this:

import Blender
from Blender import *

selected = Blender.Armature.Bones.getSelected()

for bone in selected:
     bone.setRoll(0)

Blender.Redraw()

Writing all that stuff up top seems quite inefficient not to mention (as it would appear) non-functional.

So… is there a problem with bones updating in the display in 2.4 or am I doing it wrong?

Can someone write a script that creates an armature with a couple of bones in it and then modifies the position, orientation and roll of the bones and then updates the display so I can see how it’s done?