How to add bones to armature ?
you have to switch to edit mode:
bpy.ops.object.mode_set(mode='EDIT', toggle=False) obArm = bpy.context.active_object #get the armature object ebs = obArm.data.edit_bones eb = ebs.new("BoneName") eb.head = (0, 1, 1) # if the head and tail are the same, the bone is deleted eb.tail = (0, 1, 2) # upon returning to object mode
In addition, it’s important to understand that edit bones DO NOT exist in object mode, and if you try to keep them after a mode switch this will lead to undefined behavior. You cannot edit object bones, but they have most of the same properties as edit bones. Finally, there are pose bones which contain rigging/animation data, and they are a property of object.pose rather than object.data.