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.getType() == "Armature": skeleton = selected.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:
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.