Envelope distance not changing.

I am simply running these three lines of code, which should edit the envelope distance
of all bones, and it is not showing an update in the interface. In fact, it appears to be doing
nothing whatsoever!


for b in bpy.context.object.data.bones:
    bpy.context.object.data.bones[b.name].envelope_distance = 0.03
bpy.context.scene.update()

I have also tried running this in the command line on a single bone:


bpy.context.object.data.bones['femur'].envelope_distance = 0.03

Nothing happened.

I know that the first line is working, because if I use:


for b in bpy.context.object.data.bones:
    print(b.name)

All of the bone names print out.

Any ideas?

Are you running your code in edit mode, or object mode?

if you are running it in edit mode, you need to change the data from ‘bones’ to ‘edit_bones’

Here is a simplified code for edit mode:

for b in bpy.context.object.data.edit_bones:
    b.envelope_distance = 0.03
bpy.context.scene.update()

Yowie! That was exactly what I needed! I was indeed running it in edit mode,
and that little change did exactly what I needed . . . . I ran it and it updated in the
3D view even without the third line of code. Thanks a lot . . . . that should
take care of it!

Rock on, glad it worked!

Please edit the post and add the solved prefix