Modify All Bones

I was able to access all bones but I am unable to modify them. My current code gives me an error of AttributeError: . . . "Bone" is read-only which is consistent with the documentation.
So I guess there is another way to access and actually modify them.

May I know how?

import bpy

bones = bpy.data.armatures['Deformation'].bones

for bone in bones: 
    bone.use_connect = True # line that gives the error
import bpy

bpy.context.view_layer.objects.active = bpy.data.objects['Deformation']
bpy.ops.object.mode_set(mode='EDIT')
bpy.ops.armature.select_all(action='SELECT')
bones = bpy.context.selected_bones

for bone in bones: 
    bone.use_connect = True 
    

try this

1 Like

Thanks @jerzygorskiart, Works as expected. So, I guess the key solution here is to be in the edit mode.

I think the key is to use bpy.context to change the data instead of using bpy.data which is read only i guess. I’m not sure, i’m not a programmer :slight_smile: